You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Yeah, I recall having thought about this before. It would make sense for readBody to make a request state transition. The problem is streamBody, which currently "leaks" the underlying Stream. Maybe that operation could also transition to BodyRead, but you'd be on your own in terms of safety.
dataHeadersReaddataBodyRead-- | A middleware transitioning from one `Request` state to another.typeRequestStateTransitionmreqfromtoa=forallresc.
Middlewarem
(Conn (reqfrom) resc)
(Conn (reqto) resc)
aclassRequest (req :: Type->Type) mwhere
getRequestData
::forallstateresc
. Middlewarem
(Conn (reqstate) resc)
(Conn (reqstate) resc)
RequestDataclassRequestreqm<=BaseRequestreqm-- | A `ReadableBody` instance reads the complete request body as a-- | value of type `b`. For streaming the request body, see the-- | [StreamableBody](#streamablebody) class.class (Requestreqm) <=ReadableBodyreqmbwhere
readBody
::RequestStateTransitionmreqHeadersReadBodyReadb
I'd like to pick up this issue following the same approach I proposed in #86.
I think the HeadersRead and BodyRead should be renamed to HeadersReadable and BodyReadable. Both convey the idea that those aspects are "readable" in that current state. The final transition could be FullyRead or something like that.
Just to clarify, but should there also be a type for reading the status line?
I think the HeadersRead and BodyRead should be renamed to HeadersReadable and BodyReadable. Both convey the idea that those aspects are "readable" in that current state. The final transition could be FullyRead or something like that.
IIRC (it was some time ago since I worked on this), the status line and headers are always read. The only state transition currently represented is not having read the body (HeadersRead) and (BodyRead). You could explicitly represent the prior states, too, but I'm not sure how useful it is for a user of Hyper. Only when implementing the underlying HTTP server would you care about reading status/headers (and I don't even know if the NodeJS HTTP API supports that level of control). Does that make sense?
Activity
owickstrom commentedon Sep 29, 2017
Yeah, I recall having thought about this before. It would make sense for
readBodyto make a request state transition. The problem isstreamBody, which currently "leaks" the underlyingStream. Maybe that operation could also transition toBodyRead, but you'd be on your own in terms of safety.owickstrom commentedon Sep 29, 2017
Just sketching:
owickstrom commentedon Oct 1, 2017
Maybe the
StreamableBodymethod could take the streaming consumer function as an argument, and directly changing the state of the request toBodyRead:So you'd get access to the underlying stream only inside the supplied function.
JordanMartinez commentedon Aug 6, 2019
I'd like to pick up this issue following the same approach I proposed in #86.
I think the
HeadersReadandBodyReadshould be renamed toHeadersReadableandBodyReadable. Both convey the idea that those aspects are "readable" in that current state. The final transition could beFullyReador something like that.Just to clarify, but should there also be a type for reading the status line?
owickstrom commentedon Aug 15, 2019
IIRC (it was some time ago since I worked on this), the status line and headers are always read. The only state transition currently represented is not having read the body (
HeadersRead) and (BodyRead). You could explicitly represent the prior states, too, but I'm not sure how useful it is for a user of Hyper. Only when implementing the underlying HTTP server would you care about reading status/headers (and I don't even know if the NodeJS HTTP API supports that level of control). Does that make sense?JordanMartinez commentedon Aug 15, 2019
Makes sense. I was thinking of parallels to the request state, so this came to mind.