HTTP.jl : response bodies truncated

(I assume this is because I’m doing something wrong, but if it’s just a bug I can open an issue.)

When using HTTP.jl and accessing a particular server, I find that all requests except the first lead to a truncated response. If I open a fresh Julia session and do using HTTP; HTTP.get(addr), the response has ~1600 bytes in the body. If I just repeat HTTP.get(addr) or make any other request to the same server, e.g. HTTP.get(addr * "/other/resource"), the response body always has 132 bytes. (And that response body is incomplete.)

I don’t think the problem is on the server’s end, because a) using Requests.jl I can make the same request repeatedly and get the full response; b) using two Julia sessions in parallel and HTTP.jl I can get the full response twice in rapid succession.

Details/context:

  • The server I’m trying to reach is a Hue bridge on my home network. I often set Julia to do a long computation and then wander away from the computer; it’d be cool to have my lights briefly flash green when the computation is completed. The first request in a fresh session works fine and gives the right information.
  • It doesn’t seem to matter what the first request is; the first request works fine and subsequent requests get truncated to 132 bytes.
  • I’m running Julia 0.6 on Windows
  • I’ve been unable to produce a small [non-]working example strictly locally, e.g. by having a server running on localhost give a long string in response to all requests.
  • Here is some example code showing what happens:
julia> using HTTP

julia> HUE = "http://192.168.0.100/api/<my-api-key>"
"http://192.168.0.100/api/<my-api-key>"

julia> r1 = HTTP.get(HUE * "/lights/5")
HTTP.Response:
"""
HTTP/1.1 200 OK
Connection: close
Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE, HEAD
Expires: Mon, 1 Aug 2011 09:00:00 GMT
Access-Control-Allow-Headers: Content-Type
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Access-Control-Allow-Credentials: true
Content-Type: application/json
Access-Control-Allow-Origin: *
Pragma: no-cache
Access-Control-Max-Age: 3600

[open HTTP.FIFOBuffer with 314 bytes to read]
"""

julia> String(r1)
"{\"state\":{\"on\":true,\"bri\":254,\"hue\":25500,\"sat\":254,\"effect\":\"none\",\"xy\":[0.4100,0.5172],\"ct\":290,\"alert\":\"none\",\"colormode\":\"hs\",\"reachable\":true},\"type\":\"Extended color light\",\"name\":\"Evan's nook\",\"modelid\":\"LCT001\",\"manufacturername\":\"Philips\",\"uniqueid\":\"00:17:88:01:00:ec:61:94-0b\",\"swversion\":\"5.23.1.13452\"}"

julia> r2 = HTTP.get(HUE * "/lights/5")
HTTP.Response:
"""
HTTP/1.1 200 OK
Connection: close
Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE, HEAD
Expires: Mon, 1 Aug 2011 09:00:00 GMT
Access-Control-Allow-Headers: Content-Type
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Access-Control-Allow-Credentials: true
Content-Type: application/json
Access-Control-Allow-Origin: *
Pragma: no-cache
Access-Control-Max-Age: 3600

[open HTTP.FIFOBuffer with 132 bytes to read]
"""

julia> String(r2)
"{\"state\":{\"on\":true,\"bri\":254,\"hue\":25500,\"sat\":254,\"effect\":\"none\",\"xy\":[0.4100,0.5172],\"ct\":290,\"alert\":\"none\",\"colormode\":\"hs\",\"r"

Is there something obvious I should be doing differently?

similar

Not just similar, identical. Dunno how I missed that, I guess I wasn’t looking in the closed issues.