3

I need to upload a gzipped file. For performance in case my string gets too big I decided to use streams but ran into an issue with the server requiring a content-length header which cannot be calculated as the gzipping is inline. I then decided to use chunked transfer but am not sure if I am either not doing this correctly or if the server will simply not accepting streams/chunks as it still returns an error about needing a content-length header.

Here's the bit of the code:

const gzip = zlib.createGzip()
let stream = createStream(string) // I also use files hence the streaming
  .pipe(gzip) )
  .pipe(request.put(url, {
    headers: {
      'Transfer-Encoding': 'chunked',
      'x-ms-blob-type': 'blockblob'
    }
}))

Response:

Content-Length HTTP header is missing

I've also played around with adding other headers such as:

'Content-Type': 'application/javascript'
'Content-Encoding': 'gzip'

Is my only option to just forgo streaming or gzip out of the flow and calculate length that way? I can't tell if I am missing something or of the server is being persnickety.

cyberwombat
  • 38,105
  • 35
  • 175
  • 251
  • Sounds like the server doesn't accept or understand chunked encoding, since the use of such implies that `content-length` is unnecessary, and vice versa. – Ian Kemp Apr 15 '19 at 12:33

0 Answers0