-->
Page 1 of 1

A simple GET respond from Amazon ?

PostPosted: Fri Oct 16, 2015 9:46 am
by rant
Keep getting bad request respond from the server , and if i remove the \r\n at the end i dont get even this .
Seems there is a problem with my cr nl .

This code ,


Code: Select all char *hdr[] =
          {
             
            "GET /index.php HTTP/1.1\r\n ",
            "Host:x2.xx.xxx.xx\r\n ",
            "User-Agent:runscope/0.1\r\n ",
            "Accept-Encoding:gzip, deflate\r\n",
            "Accept-Language:en-us\r\n",
            "Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n",
            "Connection:close\r\n\r\n",
             NULL
          };

          total_len=0;
          for(int i=0; hdr[i]!=NULL; i++)  // get total length of data to send
            total_len+=strlen(hdr[i]);
         
           // set channel and length of transfer
          sprintf(cmd,"AT+CIPSEND=%d,%d",id,total_len);
          wifiSerial.println(cmd);
         
            // wait for '>' and send data
          if( waitFor( ">", 5000 ) )
          {
            for(int i=0; hdr[i]!=NULL; i++)
              wifiSerial.print(hdr[i]);




produce in the terminal this ( in one line !!! ) :

Code: Select allAT+CIPSEND=0,218


OK
> GET /index.php HTTP/1.1
 Host:xx.xx.xxx.xx
 User-Agent:runscope/0.1
 Accept-Encoding:gzip, deflate
Accept-Language:en-us
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Connection:close


Recv 218 bytes

SEND OK



and here there is the bad respond error ( +ipd etc )