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

tool/-T: perform non-chunked transfer for stdin if it is a regular file #12178

Closed
wants to merge 2 commits into from

Commits on Oct 24, 2023

  1. Configuration menu
    Copy the full SHA
    b0a6993 View commit details
    Browse the repository at this point in the history
  2. tool/-T: perform non-chunked transfer for stdin if it is a regular file

    curl will now also compute the content-length of the transfer if stdin
    is the file to upload and stdin is a regular file, using its file size.
    
    Since, while being a regular file, stdin could not have its offset at
    the start of the file, curl will now also get the current offset into
    the upload file's file descriptor and use (filesize - offset) as
    content-length for transfer instead of just using the full filesize.
    This also fixes a bug on BSDs where open("/dev/fd/N") behaves like
    dup(N), so, if N is a file descriptor to a regular file, the file offset
    of the file descriptor returned by open() may not have been at the start
    of the file despite curl's previous assumption.
    
    Since I don't know anything about VMS systems, I left the behaviour for
    VMS unchanged; on VMS, curl will still perform a chunked transfer if the
    upload file is stdin.
    
    I updated tests that were testing chunked transfers for stdin to use
    <stdin pipe="yes"> since now curl only performs a chunked transfer by
    default if the upload file (stdin or not) is not a regular file.
    And I added a new test (268) that verifies that stdin is uploaded with
    content-length (not transfer-encoding:chunked) if it is a regular file.
    
    Fixes curl#12171
    Fixes curl#12177
    emanuele6 committed Oct 24, 2023
    Configuration menu
    Copy the full SHA
    b1e1799 View commit details
    Browse the repository at this point in the history