Skip to content

HTTP message body lost when uploading a file and a redirection occurs #887

@nicolasferreiralozano

Description

@nicolasferreiralozano

When the SDK makes an HTTP request to any of the upload URLs and the HTTP response is 307 Temporary Redirect, or possibly any other redirection, the SDK correctly follows the redirection but drops the HTTP message body, causing the server to respond with a client error.

A real-world scenario could be a proxy server sitting between the client and the server, needing to authenticate the upload URL, redirecting the client to perform authentication before allowing the client to proceed with the request. In this case, the SDK would POST the usual multipart/form-data to https://upload.box.com/api/2.0/files/content, receive a 307 Temporary Redirect, and POST to Location without the HTTP message body, which is incorrect.

A few observations:

  • A quick glance at the SDK's source code suggests that the issue is that the stream used for uploads by the SDK is not rewindable.
  • Requests works correctly. Requests correctly follows the redirection and maintains the HTTP message body. Requests had this bug in 2016, but it was fixed: requests gets stuck on post redirect where data is readable psf/requests#3079
  • The auto-generated Python SDK has the same problem.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions