Giter VIP home page Giter VIP logo

Comments (3)

garnaat avatar garnaat commented on July 24, 2024

I'm assuming that the bucket you were trying to write to was a newly created bucket?

In that case, you can receive a temporary redirect (307) when you try to access the bucket because the DNS records that have to be created to resolve the bucket using virtual-hosted addressing have not yet propagated throughout the network.

This 307 redirect should, however, contain a Location header. Are you sure there was no location header present?

from botocore.

jamesls avatar jamesls commented on July 24, 2024

Did more digging into this. You do get a location header with the region specific endpoint (bucket.s3region.amazonaws.com), but the problem is that the fileobj has been exhausted so .read() returns nothing. When you send the request to the new location it waits for content-length bytes, but eventually s3 closes the socket on their end.

Does requests provide anything to rewind a stream? Is this something we could do before requests retries the request?

from botocore.

jamesls avatar jamesls commented on July 24, 2024

I spent more time researching this and have a few observations:

  • The ideal way to handle this would be through an Expect: 100-continue header. From the research I've done it seems like httplib does not properly support this. It will handle a 100 continue response but it already sends the body. I also double checked that requests/urllib3 does not support 100 continue.
  • The requests library has a hook when a request is received, this includes redirect responses. We could add a hook that .seek(0)'s the body on redirects, otherwise it raises an error if it's not seekable. The only downside here is that we're potentially sending part of the body twice.

The reason I'd like to get this implemented is for better memory utilization in this branch of the CLI: https://github.com/jamesls/aws-cli/compare/memory-utilization

This branch is ready to go, except that by switching from bytearrays to file objects, we run into this issue here.

from botocore.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.