I am facing some problem with GPRS Project. I am sending request to server through GPRS and receiving responce from the server. I have used AVR ATmega32 micro controller and SIM900 GSM/GPRS Module from simcom. I can send HTTP Request Header Successfully to the server, but getting Bad Request response every time. I have wrote program in AVR Studio 6.2. here I have attached Response of Server received on GPRS.
AT
OK
AT+CSMINS?
+CSMINS: 0,1
OK
AT+CREG?
+CREG: 0,1
OK
AT+CGATT?
+CGATT: 1
OK
AT+CIPSHUT
SHUT OK
AT+CIPSTATUS
OK
STATE:IP INITIAL
AT+CIPMUX=0
OK
AT+CSTT="idea gprs"
OK
AT+CIICR
OK
AT+CIFSR
10.112.37.103
AT+CIPSTART= "TCP","198.136.54.34","80"
OK
CONNECT OK
AT+CIPSEND
> GET /httptest.php?data1=value1 HTTP/1.1
Host: http://exqure.com
SEND OK
HTTP/1.1 400 Bad Request
Date: Thu, 18 Jun 2015 12:19:34 GMT
Server: Apache
Content-Length: 226
Connection: close
Content-Type: text/html; charset=iso-8859-1
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
</p>
</body></html>
I want to under stand that where I am going wrong? What is the correct format for HTTP header request?
Here is my Code :
//////////////////////////////////////////////////////////////////////////
// SEND DATA
//////////////////////////////////////////////////////////////////////////
LCD_ClearScreen();
LCD_goto_XY(1,1);
LCD_Print("Sending DATA");
_delay_ms(1000);
LCD_ClearScreen();
r=SIM300SendDATA(0,"/httptest.php?data1=value1","http://exqure.com");
if (r==SIM300_FAIL)
{
}
int8_t SIM300SendDATA(uint8_t *Method,char *PATH,char *HOST)
{
UFlushBuffer();
//UWriteString(num);
char cmd[25]="AT+CIPSEND",DataToSend[255];
//char GET2[255]="";
//char CRLF[4]="\r\n\r\n";
//Send Command
SIM300Cmd(cmd);
_delay_ms(200);
uint8_t len = SIM300GPRSWaitForResponse(1000);
if(len)
{
if (!Method)
{
sprintf(DataToSend, "GET %s HTTP/1.1\r\n Host: %s\r\n\r\n", PATH, HOST);
}
else
{
sprintf(DataToSend, "POST %s HTTP/1.1\r\n Host: %s\r\n", PATH,HOST);
}
}
else
{
return SIM300_TIMEOUT;
}
UWriteString(DataToSend);
//UWriteString(GET2);
//UWriteString(CRLF);
UWriteData(0x1A);
len=SIM300WaitForResponse(1000);
if(len==0)
return SIM300_TIMEOUT;
sim300_buffer[len-1]='\0';
if(strncasecmp(sim300_buffer+2,"CMGS:",5)==0)
{
UFlushBuffer();
return SIM300_OK;
}
else
{
UFlushBuffer();
return SIM300_FAIL;
}
}