JuliaWeb / GnuTLS.jl

Transport Level Security for Julia Streams provided by GnuTLS
Other
8 stars 13 forks source link

gzipped data is coming through funny #27

Open jkroso opened 9 years ago

jkroso commented 9 years ago

I would expect the following script to have the same output as curl -H "Accept-Encoding: gzip" https://api.github.com:443/repos/JuliaWeb/GnuTLS.jl/git/refs/heads/master. But it seems to be quite different. They have a similar length 184 bytes vs 189 but otherwise completely different. If I remove the "Accept-Encoding: gzip" header the results match up.

using GnuTLS

sess = GnuTLS.Session()
set_priority_string!(sess)
set_credentials!(sess, GnuTLS.CertificateStore())
associate_stream(sess, connect("api.github.com", 443))
handshake!(sess)
write(sess, """GET /repos/JuliaWeb/GnuTLS.jl/git/refs/heads/master HTTP/1.1\r
User-Agent: Julia/$VERSION\r
Host: api.github.com\r
Accept: */*\r
Accept-Encoding: gzip\r
\r
""")

readuntil(sess, "\r\n\r\n")

while !eof(sess)
  write(STDOUT, read(sess, Uint8))
end

Bountysource

sbromberger commented 9 years ago

Does it work if you use readavailable() or readall() instead of read() (as discussed in #26?

jkroso commented 9 years ago

No I still get the same output. Thanks though was worth a try

sbromberger commented 9 years ago

Edited the title because I'm not sure we want to set this sort of precedent.