Skip to content

Getting a request's body seems overly complex #7

Closed
@icambridge

Description

@icambridge

So just been in chat asking about getting the request body. I just think it could be improved and this seems like a better forum, since it's got longer text.

@igorw and @cboden pointed out that it's meant to be streamed/piped. And were helpful in pointing me in the direction of the information to get the request body. I can achieve getting the body data in multiple ways, but in each case it seems that I'm getting the data after the request has finished. This could just be me doing it wrong. My latest trial can be found at https://gist.github.com/icambridge/d8c1ea63cce6733bc5d5 I did also manage to get the data using the on data event and again this was executed after the request was over.

I think personally that the body should be an attribute in request object as it clearly belongs to that request. I also think it should be easy to fetch. I do understand the desire to keep memory low when you don't know what size the body will be, however in some cases you have a rough idea and that it could be small. So my idea is to refactor the server class so you can change RequestHeaderParser if you desire to so it returns a BodiedRequest object so if you want it to be a simple getBody you can do so. I'm willing to do the leg work I just don't want to spend time doing then have some point out all the things wrong with that approach.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions