HttpClient library: Issues when POSTing data

Hey all,

I’m trying to use HttpClient to POST some simple data to a web server on my local network. Nothing too fancy.

With logging enabled, the output for the request is as you would expect:

HttpClient>	Connecting to IP: 192.168.1.66:8080
HttpClient>	Start of HTTP Request.
POST /api/report HTTP/1.0
Connection: close
Content-Length: 25
Content-Type: application/json
Accept: */*
{"temperature":79.600000}
HttpClient>	End of HTTP Request.

Where things get dicey is when the response comes back:

HttpClient>	Receiving TCP transaction of 94 bytes.
HTTP/1.1 200 OK
Content-Length: 19
Content-Type: application/json
Server: Swifter 1.3.3


HttpClient>	End of TCP transaction.
HttpClient>	End of HTTP Response (416ms).
HttpClient>	Status Code: 200

The 94 bytes of data represent the HTTP header info, but not the body. A TCP transaction of 19 bytes that contains the body of the response never comes through :frowning:

What’s really strange is if I change it from a POST request to a GET request and just have my web server send back the same data in both cases, it works:

HttpClient>	Connecting to IP: 192.168.1.66:8080
HttpClient>	Start of HTTP Request.
GET /api/report HTTP/1.0
Connection: close
Content-Type: application/json
Accept: */*
HttpClient>	End of HTTP Request.

HttpClient>	Receiving TCP transaction of 94 bytes.
HTTP/1.1 200 OK
Content-Length: 19
Content-Type: application/json
Server: Swifter 1.3.3


HttpClient>	End of TCP transaction.
HttpClient>	Receiving TCP transaction of 19 bytes.
{"pollingRate":500}
HttpClient>	End of TCP transaction.
HttpClient>	End of HTTP Response (899ms).
HttpClient>	Status Code: 200

I can’t see why the processing of the incoming data would be any different for the POST than for the GET. When I curl both methods, or use any number of other REST clients, the responses for the GET and POST both come back as expected. That leads me to believe that my server code is ok.

I’ve seen a few other related posts, namely here, here, and here that also address some issues related to POSTing data with the HttpClient library, but none seem to have exactly the same behavior.

So, the library works great for GET requests, but can anyone share their experience on how it’s working with POST requests? Or, what’s the best practice for HTTP client requests on the photon? As far as alternatives, there don’t seem to be too many.

Should we ever expect native support for HTTP requests? What about building or porting an existing C library (curl?).

Any guidance would be greatly appreciated! Thanks!

I’m seeing similar behavior trying to retrieve the full contents of a POST message, using the HttpClient library. Any one else seen this before, or know of a workaround?