Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[XrdHttp] Add back parsing of Transfer-Encoding header #2059

Merged
merged 1 commit into from
Aug 4, 2023

Conversation

CohenQU
Copy link
Contributor

@CohenQU CohenQU commented Jul 17, 2023

This commit reintroduces a header parser for Transfer-Encoding: chunked to maintain compatibility with the EGI Nagios probe. This issue was first mentioned in #2058.

Fixes: d96b2b70487e159b47c24925abcfa00f975ec3d6, #2009

@CohenQU CohenQU marked this pull request as draft July 17, 2023 15:29
@CohenQU CohenQU marked this pull request as ready for review July 17, 2023 15:29
@olifre
Copy link
Contributor

olifre commented Jul 17, 2023

Thanks for the patch! As already mentioned in the linked issue, I can confirm that this fixes the EGI probe (and other use cases using Transfer-Encoding: chunked) in my testing.
It still feels a bit surprising that setting the status header also toggles the transfer-encoding, so I would be curious as to which clients require this workaround (maybe it is also possible to fix these in their corresponding upstreams instead).

@CohenQU
Copy link
Contributor Author

CohenQU commented Jul 17, 2023

@olifre
One example is the osdf-client, where we create the HTTP request by using net/http package (line 453). However, the workaround seems a necessary step for all clients implemented with golang, until there is any update on their end.

The issue we encountered before is as follows. In Golang, we can set headers in HTTP GET requests through:

req.HTTPRequest.Header.Set("X-Transfer-Status", "true")
req.HTTPRequest.Header.Set("TE", "trailers")
req.HTTPRequest.Header.Set("Transfer-Encoding", "chunked")

However, the XRootD server is only able to capture the X-Transfer-Status and TE headers when parsing the headers, while the Transfer-Encoding header is missing. Our analysis suggests that the Go HTTP client is automatically handling the chunking of the request body, which result in the removal of the Transfer-Encoding header from the outgoing request. And this is why we came up with the workaround we discussed before.

Copy link
Contributor

@ccaffy ccaffy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good for me.

@olifre
Copy link
Contributor

olifre commented Jul 17, 2023

One example is the osdf-client, where we create the HTTP request by using net/http package (line 453). However, the workaround seems a necessary step for all clients implemented with golang, until there is any update on their end.

Thanks for the details!

I did not find the actual bug in osdf-client yet, since my Go knowledge is limited, but using and modifying a simple example such as https://gist.github.com/yinchunxiang/ef170ce11927a2f057a32870e2dd4cd2 yields a working request with the headers:

POST / HTTP/1.1
Host: localhost:9999
User-Agent: Go-http-client/1.1
Transfer-Encoding: chunked
Content-Type: application/json
Te: trailers
X-Transfer-Status: true

So this is not a general bug in net/http, but likely a problem in the way it is used by osdf-client (maybe since the HTTP version is not fixed to 1.1, and Transfer-Encoding: chunked is forbidden in HTTP/2, or maybe the Content-Length header is set accidentally?).

In any case, since osdf-client seems to be the only problematic client, we could move this part of the discussion over to osdf-client if you like — it seems it's a bug in that client which could be fixed (and subsequently, the client-specific workaround in XRootD could be dropped?).

So the TL;DR would be: For sure the fix in this issue should go in, but maybe the workaround which is still in can also be removed once the problematic client is fixed ;-).

@CohenQU
Copy link
Contributor Author

CohenQU commented Jul 17, 2023

@olifre I concur with your recommendations. I will initiate a dialogue with the developers on the osdf-client side to address the issue. Once we have implemented the necessary changes, I will then proceed to establish an additional PR here. Thank you for your invaluable input.

@olifre
Copy link
Contributor

olifre commented Jul 17, 2023

@CohenQU Thanks a lot to you, too! Since this will also make osdf-client compatible with other servers (even though likely XRootD is the only server used there, if I understand it correctly), fixing this on the client side is for sure also good for compatibility in general.

@amadio
Copy link
Member

amadio commented Jul 25, 2023

@CohenQU I think the commit message could be improved, but the patch itself looks good to go. I'd use [XrdHttp] Add back parsing of Transfer-Encoding header or something like that, and also a reference to the commit that removed it with Fixes: <commit hash>, <issue#>. Thanks!

@amadio amadio self-assigned this Jul 25, 2023
@amadio amadio added this to the 5.6.2 milestone Jul 25, 2023
@amadio amadio linked an issue Jul 25, 2023 that may be closed by this pull request
@CohenQU CohenQU changed the title Patch for HTTP Header Handling [XrdHttp] Add back parsing of Transfer-Encoding header Aug 3, 2023
@CohenQU
Copy link
Contributor Author

CohenQU commented Aug 3, 2023

@amadio The commit message is updated.

@amadio
Copy link
Member

amadio commented Aug 3, 2023

Only the title of the pull request has been updated, the commit message remains the same.

This commit reintroduces a header parser for Transfer-Encoding: chunked to maintain compatibility with the EGI Nagios probe. This issue was first mentioned in xrootd#2058.

Fixes: d96b2b7, xrootd#2009
@CohenQU
Copy link
Contributor Author

CohenQU commented Aug 4, 2023

@amadio Sorry, the update on my local branch didn't seem to deploy well, but it should be updated now.

@amadio amadio changed the base branch from master to devel August 4, 2023 06:06
@amadio
Copy link
Member

amadio commented Aug 4, 2023

Thank you! I am merging, but please note that the issue will only close when I merge the devel branch into master, you do not need to close that by hand.

@amadio amadio merged commit 01c6f07 into xrootd:devel Aug 4, 2023
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Regression] Chunked PUT creates empty files with 5.6.1 XrdHTTP
4 participants