-
Notifications
You must be signed in to change notification settings - Fork 193
Rolling Notes
==== scenarios -- request related
is the request body rewindable?
form reading should induce rewindability if not present?
-- response
is the response body clearable?
- Response.Body.CanSeek && headers not sent
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 bypass buffering if something requests that
how would something like MVC do a quick-push at a flush-point?
- fwk would induce WTFBIGY mode, and do actual writes to memory stream. at a flush-point the accumulated memory stream is copied to the response body.
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
- Unspecified:
- If full-response-buffering is in effect, application should expect content-length response header
- If buffering is not in effect, or flush has been called, application should expect chunked response header
==== first class api-
bool HttpResponse.CanClear { get{
true if Response.Body.CanSeek && !ResponseHeadersSent
}}
void HttpResponse.Clear() {
reset body and headers.
}
implicit API-
on the dictionary:
Response.Headers.Clear -> reasonable best-effort of server to return to original state
on the stream:
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
Request/Response features related to overall-timing and overall-events.
Http Request TimeStamp started (DateTimeOffset.UtcNow)
// last chance to change headers
Http Response headers sent (already have this one)
// when server sees app func complete (implying body is fully written)
Http Response completed event
// pure cleanup
Http Response AddDisposable(IDisposable)
It's not clear if both of the last two are needed
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?
- TBD next meeting