Login  
Search All Forums
Dart Home | PowerTCP Winsock for ActiveX | Custom Development Reply | PowerTCP Winsock for ActiveX Topics | Forums   
AuthorForum: PowerTCP Winsock for ActiveX
Topic: Why does a small HTTP POST response get split into two ?
roofrack
gary.roussak@tyrrellsystems.com

From: Leigh, United Kingdom
Posts: 23
Member Since: 06/08/06
posted April 15, 2014 7:22 AM

I have a Dart TCP receiving an HTTP-formatted response from a third-party module written (by me) in Java. The response is sent back using the HttpServer class from the fairly well-known com.sun.net.httpserver package.

Because both pieces of software are under my control, you will notice there's not much in the way of HTTP headers -- I don't think there needs to be.

What's happening is that the Java code is returning a JSON-formatted response to a POST, along the following typical lines:

HTTP/1.1 200 OK
Content-type: application/json
Content-length: 31
Date: Tue, 15 Apr 2014 07:52:34 GMT

{"tt":3,"tid":1,"v":"1","out":0}

As you can see, the whole packet is only about 150 bytes. However, my Dart socket's receive() subroutine always gets called twice, once for everything upto the end of the last header, and once more for the response body (the JSON data). This happens EVERY time.

Is this splitting of the packet by design on Dart's side ? Is there any way of guaranteeing only one complete self-contained receive() call for this typical size of data, or must I *always* look for a "Content-Length" header and search for that length of body data ?

Thanks

Nick B (Admin)

From: Utica, NY USA
Posts: 619
Member Since: 05/25/10

Extra Support Options
Custom Application Development

posted April 15, 2014 9:11 AM

Hello,

This is not by design on Dart's side. For TCP communication in general, data is not guaranteed to be received all at the same time. This is the reason that length information such as the Content-length header is included in protocols built upon TCP.

------
-Non-current subscribers must contact sales@dart.com to update subscription and receive continued support as needed.
------

Reply | PowerTCP Winsock for ActiveX Topics | Forums   
This site is powered by PowerTCP WebServer Tool PowerTCP WebServer for ActiveX