i have symfony2 application using guzzle http client send request server in order retrieve contents of json file. guzzle response gets transformed symfony2 response browser.
the guzzle response comes following headers:
content-encoding: gzip content-length: 2255 content-type: application/json
when outputting data ui/browser notice gets cut off because content-length incorrect. size of file closer 4905 bytes, not 2255. 2255 exact length of data cut-off point. suspect 2255 size of gzipped data , gets uncompressed @ point without updating content-length. did verify of data back, content-length header honored why data gets cut off when forward browser. interestingly, hitting url json file directly yields full contents though content-length 2255 means gets ignored chrome when hitting file directly. same if use postman rest client make request - full contents displayed.
by default, guzzle has request option decode_content = true how responses should handled. set false when submitting request didn't seem resolve issue.
before converting guzzle response symfony response removed content-length header , seems solve problem not sure that's best approach since rfc protocol states content-length header should present unless transfer-encoding header present, isn't. https://www.w3.org/protocols/rfc2616/rfc2616-sec4.html
another alternative is, since streamed response, size of stream , correct content-length, guzzle implementation uses strlen() has undesirable affect of reading whole stream.
what possible issues might run if choose omit content-length header? , alternatively, there way true length of contents without reading whole stream , update content-length header correct amount?
Comments
Post a Comment