mirror of
https://github.com/fsouza/fake-gcs-server.git
synced 2026-04-25 21:55:56 +03:00
[GH-ISSUE #1281] Resumable upload fails due to the "Location" header in the server's response #184
Labels
No labels
bug
compatibility-issue
docker
documentation
enhancement
help wanted
needs information
pull-request
question
stale
unfortunate
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/fake-gcs-server#184
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @manoss96 on GitHub (Aug 7, 2023).
Original GitHub issue: https://github.com/fsouza/fake-gcs-server/issues/1281
First of all, thanks for creating this project, it's pretty cool!
As I was trying to perform a resumable upload via the GCS Python API, I noticed that even though I could create and initiate a resumable upload session without any issues, the program would stall while attempting to transfer the first chunk of bytes. Having dug into the code a little bit, I figured out it was due to the server's response to the resumable upload session initiation request, more specifically, due to the response's
Locationheader. What happens is essentially this:https://127.0.0.1:4443/upload/storage/v1/b/bucket/o?uploadType=resumable&name={FILE_NAME}Locationheader includes the initial request's URL, only this time it includes anupload_id. However,127.0.0.1within the original URL has been turned into0.0.0.0. Thus, the header contains something like this:https://0.0.0.0:4443/upload/storage/v1/b/bucket/o?uploadType=resumable&name={FILE_NAME}&upload_id={UPLOAD_ID}.upoad_idand completely replaces the original URL. Therefore, when it attempts to upload the first chunk of bytes, the request is sent tohttps://0.0.0.0:4443instead ofhttps://127.0.0.1:4443, causing it to stall.I've tested this by manually replacing
0.0.0.0with127.0.0.1and it works just fine.@fsouza commented on GitHub (Aug 12, 2023):
Can you share the command line you used to start the server and a snippet of code to reproduce the issue?
@manoss96 commented on GitHub (Aug 12, 2023):
@fsouza Sure, the server was started as such:
Then, a resumable upload was attempted via the Python API as such:
Just make sure to
pip install google-cloud-storage==2.10.0on Python 3.10 and you're good. Also, I should note that this was attempted on a Windows 10 system. I'm only mentioning this because I believe that Linux systems treat0.0.0.0differently (https://stackoverflow.com/a/21057696/19957744). It might work just fine on a Linux machine, then again, I haven't tested it.@manuteleco commented on GitHub (Aug 19, 2023):
I stumbled upon the same issue. Turns out you have to pass the
-external-urlparameter when runningfake-gcs-server. In your example I believe it should be-external-url https://127.0.0.1:4443.For further detail, this is how the
Locationheader is being built:github.com/fsouza/fake-gcs-server@87dfef0e58/fakestorage/upload.go (L436-L442)github.com/fsouza/fake-gcs-server@87dfef0e58/fakestorage/server.go (L440-L449)and here some documentation about the
-external-urlattribute:github.com/fsouza/fake-gcs-server@87dfef0e58/internal/config/config.go (L75)github.com/fsouza/fake-gcs-server@87dfef0e58/fakestorage/server.go (L89-L93)@manoss96 commented on GitHub (Aug 20, 2023):
@manuteleco Tested your solution and it works perfect, thanks! @fsouza Want me to close this issue or are you planning to replace
0.0.0.0with127.0.0.1no matter theexternal-urlparam?@fsouza commented on GitHub (Sep 9, 2023):
@manoss96 I think we cannot make that replacement because not everyone uses it on localhost. Also, I'm curious, is the Python client not able to send request to https://0.0.0.0:4443 (I know it's not RFC compliant, but in my experience this just works heh)
@manoss96 commented on GitHub (Sep 9, 2023):
@fsouza I think it's more of an OS thing rather than a Python thing, but I'm not sure. Anyways, I've managed to get it to work by following @manuteleco 's instructions. Thefore, I am closing this issue.