# HTTP.jl : response bodies truncated

**URL:** <https://discourse.julialang.org/t/http-jl-response-bodies-truncated/5659>\
**Category:** Web Stack\
**Created:** [August 31, 2017, 3:12pm UTC](https://discourse.julialang.org/t/http-jl-response-bodies-truncated/5659 "2017-08-31T15:12:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![evanfields](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evanfields/32/1744_2.png) [@evanfields](https://discourse.julialang.org/u/evanfields)\
**Post date:** [August 31, 2017, 3:12pm UTC](https://discourse.julialang.org/t/http-jl-response-bodies-truncated/5659/1 "2017-08-31T15:12:49Z")

</div>

(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
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?

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [August 31, 2017, 7:39pm UTC](https://discourse.julialang.org/t/http-jl-response-bodies-truncated/5659/2 "2017-08-31T19:39:52Z")

</div>

[similar](https://github.com/JuliaWeb/HTTP.jl/issues/58)

---

<div class="post-metadata">

**Author:** ![evanfields](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evanfields/32/1744_2.png) [@evanfields](https://discourse.julialang.org/u/evanfields)\
**Post date:** [August 31, 2017, 9:26pm UTC](https://discourse.julialang.org/t/http-jl-response-bodies-truncated/5659/3 "2017-08-31T21:26:43Z")

</div>

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