I know there are several topic about this subject, I read them but couldn’t find an answer yet.
I try to post some data to a php script on my server. Using FXT009 (FW 7.46, WIP 5.42)
On one server I get a 200 OK message, but the data I try to post is somehow not posted. I can get some data from the url with php, but php tells me there are 0 posts in the message. It doesn’t matters if I add the Content-Length header to this one.
If I try to post something to my other server I get a 411 message Content-Length required, while I have a header Length-content added to the HTTP Post.
I played something with the options like HTTP 1.0, but that won’t work either. I get messages like not authorized and couldn’t find save.php
static s32 http_ClientCreate(wip_bearer_t Br_Id)
{
s32 ret = 0;
char *ip = disp_ip(Br_Id);
wm_sprintf(Data_Send,"ip=%s&go=go&henk=h&flip+iee=ooo",ip);
char conlen[3];
ascii url[50];
wm_sprintf(url,"http://urlname.nl/save.php?ip=%s",ip);
wm_sprintf(conlen,"%d",strlen(Data_Send)+1);
adl_atSendResponse ( ADL_AT_UNS, conlen);
TRACE(( 1, "CONLEN = %03d",strlen(Data_Send)+1));
// HTTP Session creation
http_ClientCtx.HttpCnxCh = wip_HTTPClientCreateOpts(
NULL,NULL,WIP_COPT_HTTP_VERSION,WIP_HTTP_VERSION_1_1,
WIP_COPT_HTTP_HEADER, "User-Agent", "WIPHTTP/1.1",
WIP_COPT_END);
if (http_ClientCtx.HttpCnxCh == NULL)
{
TRACE(( 1, "Cannot create HTTP session channel\n" ));
ret = -1;
}
else
{
// HTTP POST command
http_ClientCtx.HttpDataCh = wip_getFileOpts(
http_ClientCtx.HttpCnxCh,
url,
HttpDataHandler,
&http_ClientCtx,
WIP_COPT_HTTP_METHOD, WIP_HTTP_METHOD_POST,
WIP_COPT_HTTP_HEADER, "Accept", "text/html",
WIP_COPT_HTTP_HEADER, "Content-Length", conlen,
WIP_COPT_HTTP_HEADER, "Content-Type", "application/x-www-form-urlencoded",
WIP_COPT_END);
if (http_ClientCtx.HttpDataCh == NULL)
{
TRACE(( 1, "Cannot create http data channel" ));
wip_close( http_ClientCtx.HttpCnxCh);
ret =-1;
}else{
TRACE(( 1, "Created HTTP data channel" ));
}
}
return(ret);
}
case WIP_CEV_WRITE:
TRACE((1,"CEV write data:"));
TRACE((1,Data_Send));
BytesWritten = wip_write( http_ClientCtx.HttpDataCh, Data_Send, (strlen(Data_Send)+1)-Sent_Bytes);
if(BytesWritten < 0){
TRACE((1,"Error sending data :("));
return;
}
Sent_Bytes += BytesWritten; // Update the number of bytes sent.
if( Sent_Bytes == strlen(Data_Send)+1){ // All data sent
TRACE((1,"HttpDataHandler: All data send"));
}
if(wip_shutdown( http_ClientCtx.HttpDataCh,FALSE,TRUE)==0){
TRACE((1,"wip_shutdown"));
}else{
TRACE((1,"wip_shutdown error"));
}
break;
Traces:
2012/03/09;10:22:42:431;001;ADL;1;Bear ip connected
2012/03/09;10:22:42:434;001;ADL;1;CONLEN = 042
2012/03/09;10:22:42:438;001;ADL;1;Created HTTP data channel
2012/03/09;10:22:43:326;001;ADL;1;Cev open
2012/03/09;10:22:43:331;001;ADL;1;CEV write data:
2012/03/09;10:22:43:339;001;ADL;1;ip=83.232.10.37&go=go&henk=h&flip+iee=ooo
2012/03/09;10:22:43:344;001;ADL;1;HttpDataHandler: All data send
2012/03/09;10:22:43:347;001;ADL;1;wip_shutdown
2012/03/09;10:22:44:541;001;ADL;1;Cev read
2012/03/09;10:22:44:547;001;ADL;1;HttpDataHandler: read 174 bytes<LF>
2012/03/09;10:22:44:559;001;ADL;1;HttpDataHandler: WIP_CEV_PEER_CLOSE<LF>
2012/03/09;10:22:44:573;001;ADL;1;HTTP Error :(
2012/03/09;10:22:44:577;001;ADL;1;HttpDataHandler: Status=411<LF>
2012/03/09;10:22:44:583;001;ADL;4;HttpDataHandler: Reason="Length Required"<LF>
2012/03/09;10:22:44:588;001;ADL;1;HttpDataHandler: Content Type="text/html"<LF>
2012/03/09;10:22:44:593;001;ADL;1;HttpDataHandler: Response Length=174 bytes<LF>
2012/03/09;10:22:44:596;001;ADL;1;Cev Close
I hope there is somehow a solution for this. I tried to post data to save.php via a browser, then everything works so it seems my php script is ok. I don’t know how to sniff the HTTP packet which comes from the fxt009, otherwise I could check the contents and if there is something wrong with it.