I have a char array that is filled with the request to a server ,
in the first option which is the same as the second, it WORKS :
int total_len=0;
int id=0;
char cmd[64];
char *hdr[] =
{
"GET /index.php HTTP/1.1\r\nHost:XX.X1.XXX.1X\r\nUser-Agent:runscope/0.1\r\nContent-Type:application/json\r\nConnection:close\r\n\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]);
In the second which is exactly the same, but the request array is looks like this :
char *hdr[] =
{
"GET /index.php HTTP/1.1\r\n ",
"Host:xx.xx.xxx.xx\r\n ",
"User-Agent:runscope/0.1\r\n ",
"Content-Type:application/json\r\n ",
"Connection:close\r\n\r\n\r\n",
NULL
};
they print the same but only the first is working.On the second i get bad request because its structure is not good. Why ?