-
Notifications
You must be signed in to change notification settings - Fork 521
Minor perf and logging support changes #256
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -402,12 +402,16 @@ public void ProduceContinue() | |
{ | ||
if (_responseStarted) return; | ||
|
||
StringValues expect; | ||
if (HttpVersion.Equals("HTTP/1.1") && | ||
RequestHeaders.TryGetValue("Expect", out expect) && | ||
(expect.FirstOrDefault() ?? "").Equals("100-continue", StringComparison.OrdinalIgnoreCase)) | ||
if (HttpVersion.Equals("HTTP/1.1")) | ||
{ | ||
SocketOutput.Write(_continueBytes); | ||
foreach(var expect in _requestHeaders.HeaderExpect) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: format here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. space after foreach |
||
{ | ||
if (expect.Equals("100-continue", StringComparison.OrdinalIgnoreCase)) | ||
{ | ||
SocketOutput.Write(_continueBytes); | ||
return; | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,13 +23,7 @@ public FrameResponseStream(FrameContext context) | |
|
||
public override bool CanWrite => true; | ||
|
||
public override long Length | ||
{ | ||
get | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
public override long Length => Position; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Length is only expected to be available for seekable streams. https://msdn.microsoft.com/en-us/library/system.io.stream.length(v=vs.110).aspx There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we just add a new property to FrameResponseStream. @lodejard where were you planning on logging the this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From hosting, corresponding to "bytes written" you see in server logs. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this logging meant to be server agnostic? Would using Stream.Length work for WebListener? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No it won't, and it won't work for Nowin either. aspnet/Hosting#403 (comment) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Both of those could easily be updated. But the idea you suggested of having a request statistics feature should also be considered. |
||
|
||
public override long Position { get; set; } | ||
|
||
|
@@ -60,11 +54,13 @@ public override int Read(byte[] buffer, int offset, int count) | |
|
||
public override void Write(byte[] buffer, int offset, int count) | ||
{ | ||
Position += count; | ||
_context.FrameControl.Write(new ArraySegment<byte>(buffer, offset, count)); | ||
} | ||
|
||
public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) | ||
{ | ||
Position += count; | ||
return _context.FrameControl.WriteAsync(new ArraySegment<byte>(buffer, offset, count), cancellationToken); | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if one of those is whitespace only?