roast.vim icon indicating copy to clipboard operation
roast.vim copied to clipboard

Support to Chunk-Encoded Requests

Open JulioJu opened this issue 6 years ago • 3 comments

Hi !

When we could see in __roast_headers__, on each request `Content-Length is automatically append in the header request.

even if the roast file is like :

POST http://google.fr
PUT http://google.fr
DELETE http://google.fr

Note: for GET http://google.fr the Content-Length header is not added.

It's a big problem because if we want specify the header Transfer-Encoding: chunked it cause a conflict. The HTTP specification says: "Expert Info (Warning/Malformed): The Content-Length and Transfer-Encoding header must not be set together" (message from Wireshark).

See also https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Transfer-Encoding

Maybe it could be cool to have a way to not add automatically this HEADER field.

Thanks in advance.

JulioJu avatar May 23 '19 19:05 JulioJu

With curl (therefore with https://github.com/diepm/vim-rest-console/ ) to unset a field header we could simply use something like

Accept:

For instance thanks Wireshark we could know that

curl http://google.com appends some headers automatically like Accept: */*. To remove it simply use curl http://google.com -H 'Accept:. In Wireshark we see that the header Accept is not append.

JulioJu avatar May 24 '19 16:05 JulioJu

Hi Julio, I'm not explicitly adding a Content-Length header. It might be the requests library that's doing it. Can you give an example with setting the Transfer-Encoding header that demonstrates this problem please?

sharat87 avatar Jun 05 '19 10:06 sharat87

@sharat87

If you want an example, use

Transfer-Encoding: chunk
POST http://localhost:3030

You could see in the __roast-headers__ window that an header with Content-Length was appended.

As I said in the first comment, chunked request have this problem. A chunked request should not have the Content-Length header (see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Transfer-Encoding).

It seams that you must do something like http://2.python-requests.org/en/master/user/advanced/#chunk-encoded-requests

But probably it's not so important. Support Chunk-Encoded request is probably not a goal very important. Maybe nobody is interesting in this feature.

JulioJu avatar Jun 23 '19 13:06 JulioJu