Wip_write with HTTP socket


I have a question about WIP HTTP library. I’m trying to send some data usting HTTP_POST request. First of all I make HTTP client connection socket with:

http_ClientPutCtx.CnxChannel = wip_HTTPClientCreateOpts(
                                                                           NULL,  // no context
                                                                           // default headers
                                                                           WIP_COPT_HTTP_PROXY_PORT, HTTP_PORT,
                                                                           WIP_COPT_USER,"stupid" ,

In HTTP_Put_Connect_DataHandler:

http_ClientPutCtx.DataChannel = wip_getFileOpts(
                                                  http_ClientPutCtx.CnxChannel,  // session channel
                                             HTTP_STR_URL,                   // requested URL
                                             HTTP_Put_DataHandler,     // data handler     
                                                  &http_ClientPutCtx,            // context
                                                 // request headers
                                                  WIP_COPT_HTTP_HEADER, "Content-Length",tmplen ,
                                                  WIP_COPT_HTTP_HEADER, "Content-Type","application/x-www-form-urlencoded",

In HTTP_Put_DataHandler i call wip_write:

nwrite = wip_write( http_ClientPutCtx.DataChannel,"This is a test!", 15);

On the server side i see correct POST-header:
POST /icm/i5test/ HTTP/1.1
Transfer-Encoding: chunked
Authorization: Basic c3R1cGlkOmhhY2tlcg==
Content-Length: 76
Content-Type: application/x-www-form-urlencoded

but in POST-data[body] I recive this string:
This is a te

Seems like wip_write sends first string length, and last 3 bytes are lost. Anybody knows, is this a bug or a feature?

P.S. Most strange thing for me is that wip_write works well with FTP and UDP sockets in my previous projects.


A quick look over your code looks like the HTTP protocol is getting confused over the Content-Length: header.

See if you can use Chunked Transfer Encoding to shift your data around. This is supported by WIP (V5 at least).

Try removing the Content-Length Header from your call to wip_getFileOpts() and see how you get on.

BTW, don’t forget that the end of line marker in HTTP is CR LF - i.e. TWO characters…

ciao, Dave

I think (some) earlier WIP versions would only do Chunked transfers - so adding a content-length header just confused the issue…

I use WIP 3.00.09 and it supports only chunked transfer coding. Maybe in WIP 5 this problem is solved…