-
Notifications
You must be signed in to change notification settings - Fork 191
Rolling Notes
==== scenarios -- request related
is the request body rewindable?
form reading should induce rewindability if not present?
-- response
is the response body resettable?
- Response.Body.CanSeek
is the response body immediately transferring?
- don't need to know - you only need to ask for immediate writes, not detect it
how does the application induce immediate transferring before writing? how does application code use the response to assume output is sent incrementally?
- Response.WriteTheFlippingBytesIGiveYou()
- IWTFBIGYFeature.EnsureWTFBIGY()
how does the application or software ensure (1) buffering?
- middleware wraps stream
- wrapper also hooks WTFBIGY to flip back to immediage mode again
how would something like MVC do a quick-push at a flush-point?
- fwk would induce WTFBIGY mode, and have a memory stream that it drops to actual Response.Body at marks
how does middleware introduce a transfer-encoding or content-encoding?
- governed by server and software usage of standard response headers
how do servers and software interact with ownership of certain response headers?
- Content-Length: x
- App sets it, this stops server from doing chunked/close modes
- Transfer-Encoding: chunked
- If software adds chunked transfer-encoding, software has chunked and server is pass-through
- *** need to figure out what Transfer-Encoding: gzip without encoding
- Connection: close
- If app sets it, server will close socket when body has ended
how does application know what stream behaviors are in effect?
how does the application understand what response body mode is in effect?
what control does the application or middleware?
==== first class api-
bool HttpResponse.CanReset {
true if Response.Body.CanSeek && !ResponseHeadersSent
}
bool HttpResponse.TryReset() {
reset body and headers.
}
implicit API-
Response.Headers.Clear -> reasonable best-effort of server to return to original state
Response.Body.Length ||
Response.Body.Position get -> cumulative bytes sent via Write, WriteAsync, and SendFile
Response.Body.CanSeek -> indicate resetability
(if CanSeek)
Response.Body.Seek(0) ||
Response.Body.Position set = 0 -> induce reset, reverting completely
==== concept notes --- response buffering style
1) write with complete internal buildup and exit-path transfer (fully buffered)
2) write with internal buildup and size-based transfer (page-ish writing)
3) write with internal buildup and immediate transfer (async write-behind)
4) write with immediate transfer (sync write-inline)
--- entity body modes Content-Length: x Transfer-Encoding: chunked Connection: close NONE (based on request verb (HEAD) or response status ) Upgrade: (approximately == Connection: close)
where to track conversations:
- make a mockup repo
- use the mockup wiki
- onenote link
Http Request TimeStamp started (DateTimeOffset.UtcNow)
// last chance to change headers Http Response headers sent
// when server sees app func complete (implying body is fully written) Http Response completed event
// pure cleanup Http Response AddDisposable(IDisposable)
Microsoft.AspNet.Hosting
- Hosting layer should write a logger scope
- This should include a "RequestId"
- Figure out what a good request id should be
Http Request
Buffering modes:
-
has body or no?
- use request.ContentLength for predictions
- request.Body.Length always throw for now
- Request.Reading over no-body-request acts returns as if zero-length stream
-
is body rewindable?
- CanSeek==true if rewindable, false otherwise
-
when MUST you rewind it?
- if HttpRequest has read form it does not need to worry about resulting position
- if you peek at content, you MUST effectively return position to original value
-
how do you rewind it?
- if (CanSeek == true) use Seek or Position assignment
- if (CanSeek == false) reassign Request.Body with a read-through rewindable
-
if body is not rewindable, how do you rewindify it?
- stream that does something like in-memory-for-X-kb, and mem-mapped file over that size
-
what capability did GetBufferlessInputstream provide?
- true async reads in aspnet45 (x)
- instruct components which have adding rewindability to stop it
Protections against common attacks?
ResponseEnded