Skip to content

Compression broken #107

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

Closed
tballard opened this issue May 7, 2022 · 2 comments
Closed

Compression broken #107

tballard opened this issue May 7, 2022 · 2 comments

Comments

@tballard
Copy link
Contributor

tballard commented May 7, 2022

POSTing compressed data fails. For a small file, examining the bytes actually received reveals them to be "31,139,8,0,0,0,0,0,0,0,-1". The 31,139 means gzip, the -1 is end of file, the rest I suspect means "I forgot to close/finish the GZIPOutputStream. Looking for the code in requests/Requester.scala there is a section that I suspect should be changed to something like the following. Admittedly I haven't gotten my Ammonite script to use it, yet, but I'd be surprised if isn't the issue. I notice there are tests for the compression modes but they clearly proved insufficient.

if (!chunkedUpload) {
            val bytes = new ByteArrayOutputStream()
            val os = compress.wrap(connection.getOutputStream)
            data.write(os)
            os.close()
            val byteArray = bytes.toByteArray
            connection.setFixedLengthStreamingMode(byteArray.length)
            if (byteArray.nonEmpty) connection.getOutputStream.write(byteArray)
          } else {
            connection.setChunkedStreamingMode(0)
            val os = compress.wrap(connection.getOutputStream)
            data.write(os)
            os.close()
          }
}
@daddykotex
Copy link

I saw a similar issue use requests-scala from mill 0.10 but the issue disappeared when I upgrade to 0.11.

I assume there was a fix in here not too long ago, or in geny that solved it. I would think that you can close this

@lihaoyi
Copy link
Member

lihaoyi commented Jan 24, 2024

Fixed by #108

@lihaoyi lihaoyi closed this as completed Jan 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants