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

fix: remove the requirement on Content-Length on the gateway #64

Closed
wants to merge 1 commit into from

Commits on May 31, 2023

  1. fix: remove the requirement on Content-Length on the gateway

    This is not defined anywhere in the spec https://grep.app/search?q=Content-Length&filter[repo][0]=ipfs/specs and thus shouldn't be tested.
    
    Sending a Content-Length header here is fine if the remote gateway knows the size of the car.
    
    For example I am writing a very fast gateway that use indexed IPIP402 cars with a unixfs offset -> car offset index.
    This allows to use the `sendfile` syscall to send the car from the drives to the network card without copying it into memory or CPU.
    An index gives stores offset in the car for offsets in the unixfs file or directories, I need it to implement pathing (I skip parts of the car unrelevent to the request).
    I can then do a simple substraction and a few additions to get the total size of the car, if this is an info I have to compute anyway I might as well send it to the client.
    A client could use it to display an accurate download bar or preallocate correctly sized buffers, ...
    
    If the car is stored in a caching reverse proxy that already knows it's full size it could want to send the Content-Length header for the same reasons.
    
    The only consideration here is that sending a Content-Length which is missmatched with the underlying size would break things, which is true however this is a violation of the HTTP spec already because HTTP 1.1 pipelining depends on the Content-Length. The http client will catch this.
    Jorropo committed May 31, 2023
    Configuration menu
    Copy the full SHA
    53ecdbf View commit details
    Browse the repository at this point in the history