Skip to content

Commit 6905216

Browse files
committed
Releasing tag 1.5.0
1 parent 1bc76ac commit 6905216

15 files changed

+134
-213
lines changed

src/Unosquare.Labs.EmbedIO/System.Net/ChunkStream.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
#if !NET46
1+
#if CHUNKED
2+
#if !NET46
23
//
34
// System.Net.ChunkStream
45
//
@@ -376,7 +377,7 @@ private State ReadTrailer(byte[] buffer, ref int offset, int size)
376377
var reader = new StringReader(_saved.ToString());
377378
string line;
378379
while ((line = reader.ReadLine()) != null && line != "")
379-
Headers.Add(line);
380+
AddHeader(line);
380381

381382
return State.None;
382383
}
@@ -386,6 +387,14 @@ private static void ThrowProtocolViolation(string message)
386387
var we = new System.Net.WebException(message, null, System.Net.WebExceptionStatus.ServerProtocolViolation, null);
387388
throw we;
388389
}
390+
391+
internal void AddHeader(string data)
392+
{
393+
var set = data.Split(':');
394+
if (set.Length == 2)
395+
Headers[set[0].Trim()] = set[1].Trim();
396+
}
389397
}
390398
}
399+
#endif
391400
#endif

src/Unosquare.Labs.EmbedIO/System.Net/ChunkedInputStream.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
#if !NET46
1+
#if CHUNKED
2+
#if !NET46
23
//
34
// System.Net.ChunkedInputStream
45
//
@@ -35,7 +36,6 @@ namespace Unosquare.Net
3536
internal class ChunkedInputStream : RequestStream
3637
{
3738
private bool _disposed;
38-
private readonly HttpListenerContext _context;
3939
private bool _noMoreData;
4040

4141
private class ReadBufferState
@@ -61,7 +61,6 @@ public ChunkedInputStream(HttpListenerContext context, Stream stream,
6161
byte[] buffer, int offset, int length)
6262
: base(stream, buffer, offset, length)
6363
{
64-
_context = context;
6564
Decoder = new ChunkStream(context.Request.Headers);
6665
}
6766

@@ -186,5 +185,5 @@ public void Close()
186185
}
187186
}
188187
}
189-
188+
#endif
190189
#endif

src/Unosquare.Labs.EmbedIO/System.Net/HttpConnection.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,16 +179,22 @@ public RequestStream GetRequestStream(bool chunked, long contentlength)
179179
var buffer = _ms.ToArray();
180180
var length = (int) _ms.Length;
181181
_ms = null;
182+
182183
if (chunked)
183184
{
185+
#if CHUNKED
184186
_chunked = true;
185187
_context.Response.SendChunked = true;
186188
_iStream = new ChunkedInputStream(_context, Stream, buffer, _position, length - _position);
189+
#else
190+
throw new InvalidOperationException("Chunked transfer encoding is not supported");
191+
#endif
187192
}
188193
else
189194
{
190195
_iStream = new RequestStream(Stream, buffer, _position, length - _position, contentlength);
191196
}
197+
192198
return _iStream;
193199
}
194200

src/Unosquare.Labs.EmbedIO/System.Net/HttpListenerException.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#if !NET46
2-
using System;
32
using System.ComponentModel;
43
using System.Runtime.InteropServices;
54

src/Unosquare.Labs.EmbedIO/System.Net/HttpListenerRequest.cs

Lines changed: 6 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public override ChannelBinding GetChannelBinding(ChannelBindingKind kind)
8282
private bool _isChunked;
8383
private bool _kaSet;
8484
private bool _keepAlive;
85-
85+
8686
#if SSL
8787
delegate X509Certificate2 GccDelegate();
8888
GccDelegate _gccDelegate;
@@ -254,6 +254,7 @@ internal void FinishInitialization()
254254
_url = HttpListenerRequestUriBuilder.GetRequestUri(RawUrl, _url.Scheme,
255255
_url.Authority, _url.LocalPath, _url.Query);
256256

257+
#if CHUNKED
257258
if (ProtocolVersion >= HttpVersion.Version11)
258259
{
259260
var tEncoding = Headers["Transfer-Encoding"];
@@ -264,6 +265,7 @@ internal void FinishInitialization()
264265
return;
265266
}
266267
}
268+
#endif
267269

268270
if (!_isChunked && !_clSet)
269271
{
@@ -280,7 +282,7 @@ internal void FinishInitialization()
280282
output.InternalWrite(_100Continue, 0, _100Continue.Length);
281283
}
282284
}
283-
285+
284286
internal void AddHeader(string header)
285287
{
286288
var colon = header.IndexOf(':');
@@ -295,6 +297,7 @@ internal void AddHeader(string header)
295297
var val = header.Substring(colon + 1).Trim();
296298
var lower = name.ToLowerInvariant();
297299
Headers.Set(name, val);
300+
298301
switch (lower)
299302
{
300303
case "accept-language":
@@ -429,7 +432,7 @@ internal bool FlushInput()
429432
/// The accept types.
430433
/// </value>
431434
public string[] AcceptTypes { get; private set; }
432-
435+
433436
#if SSL
434437
/// <summary>
435438
/// Gets the client certificate error code.
@@ -496,25 +499,16 @@ public int ClientCertificateError
496499
/// <summary>
497500
/// Gets the request headers.
498501
/// </summary>
499-
/// <value>
500-
/// The headers.
501-
/// </value>
502502
public NameValueCollection Headers { get; }
503503

504504
/// <summary>
505505
/// Gets the HTTP method.
506506
/// </summary>
507-
/// <value>
508-
/// The HTTP method.
509-
/// </value>
510507
public string HttpMethod { get; private set; }
511508

512509
/// <summary>
513510
/// Gets the input stream.
514511
/// </summary>
515-
/// <value>
516-
/// The input stream.
517-
/// </value>
518512
public Stream InputStream
519513
{
520514
get
@@ -534,33 +528,21 @@ public Stream InputStream
534528
/// <summary>
535529
/// Gets a value indicating whether this request is authenticated.
536530
/// </summary>
537-
/// <value>
538-
/// <c>true</c> if this instance is authenticated; otherwise, <c>false</c>.
539-
/// </value>
540531
public bool IsAuthenticated => false;
541532

542533
/// <summary>
543534
/// Gets a value indicating whether this request is local.
544535
/// </summary>
545-
/// <value>
546-
/// <c>true</c> if this instance is local; otherwise, <c>false</c>.
547-
/// </value>
548536
public bool IsLocal => LocalEndPoint.Address.Equals(RemoteEndPoint.Address);
549537

550538
/// <summary>
551539
/// Gets a value indicating whether this request is under a secure connection.
552540
/// </summary>
553-
/// <value>
554-
/// <c>true</c> if this instance is secure connection; otherwise, <c>false</c>.
555-
/// </value>
556541
public bool IsSecureConnection => _context.Connection.IsSecure;
557542

558543
/// <summary>
559544
/// Gets the Keep-Alive value for this request
560545
/// </summary>
561-
/// <value>
562-
/// <c>true</c> if [keep alive]; otherwise, <c>false</c>.
563-
/// </value>
564546
public bool KeepAlive
565547
{
566548
get
@@ -594,57 +576,36 @@ public bool KeepAlive
594576
/// <summary>
595577
/// Gets the local end point.
596578
/// </summary>
597-
/// <value>
598-
/// The local end point.
599-
/// </value>
600579
public IPEndPoint LocalEndPoint => _context.Connection.LocalEndPoint;
601580

602581
/// <summary>
603582
/// Gets the protocol version.
604583
/// </summary>
605-
/// <value>
606-
/// The protocol version.
607-
/// </value>
608584
public Version ProtocolVersion { get; private set; }
609585

610586
/// <summary>
611587
/// Gets the query string.
612588
/// </summary>
613-
/// <value>
614-
/// The query string.
615-
/// </value>
616589
public NameValueCollection QueryString { get; private set; }
617590

618591
/// <summary>
619592
/// Gets the raw URL.
620593
/// </summary>
621-
/// <value>
622-
/// The raw URL.
623-
/// </value>
624594
public string RawUrl { get; private set; }
625595

626596
/// <summary>
627597
/// Gets the remote end point.
628598
/// </summary>
629-
/// <value>
630-
/// The remote end point.
631-
/// </value>
632599
public IPEndPoint RemoteEndPoint => _context.Connection.RemoteEndPoint;
633600

634601
/// <summary>
635602
/// Gets the request trace identifier.
636603
/// </summary>
637-
/// <value>
638-
/// The request trace identifier.
639-
/// </value>
640604
public Guid RequestTraceIdentifier => Guid.Empty;
641605

642606
/// <summary>
643607
/// Gets the URL.
644608
/// </summary>
645-
/// <value>
646-
/// The URL.
647-
/// </value>
648609
public Uri Url => _url;
649610

650611
/// <summary>

src/Unosquare.Labs.EmbedIO/System.Net/HttpStreamAsyncResult.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
#if !NET46
1+
#if CHUNKED
2+
#if !NET46
23
//
34
// System.Net.HttpStreamAsyncResult
45
//
@@ -96,4 +97,5 @@ public bool IsCompleted
9697
}
9798
}
9899
}
100+
#endif
99101
#endif

0 commit comments

Comments
 (0)