does anybody has developped AVB webserver by reference to the app_simple_webserver ?
I have designed an AVB webserver, it can support firefox and chrome browser successful, but can not support IE browser.
Code: Select all
//***************** portions of code *******************************
// Receive a HTTP request
void httpd_recv(chanend tcp_svr, xtcp_connection_t *conn)
{
struct httpd_state_t *hs = (struct httpd_state_t *) conn->appstate;
char data[XTCP_CLIENT_BUF_SIZE];
int len;
// Receive the data from the TCP stack
len = xtcp_recv(tcp_svr, data);
// If we already have data to send, return
if ( hs == NULL || hs->dptr != NULL)
{
return;
}
// Otherwise we have data, so parse it
parse_http_request(hs, &data[0], len);
// If we are required to send data
if (hs->dptr != NULL)
{
// Initate a send request with the TCP stack.
// It will then reply with event XTCP_REQUEST_DATA
// when it's ready to send
xtcp_init_send(tcp_svr, conn);
}
}
...
// Parses a HTTP request for a GET
void parse_http_request(httpd_state_t *hs, char *data, int len)
{
static int ack_cnt = 0 ;
int http_valid_data_flag = 0;
static int dynamic_test_cnt = 0;
static int status_test_cnt = 0;
static char chan_num, val;
// Return if we have data already
if (hs->dptr != NULL)
{
return;
}
// Test if we received a HTTP GET request
if (strncmp(data, "GET / HTTP", 10) == 0)
{
#if DEBUG_PARSE_HTTP
printstrln("receive GET webpage");
#endif
load_data_in_flash(AVB_WPAGE_START_ADDR, AVB_WPAGE_LENGTH, wpage_buf);
hs->dptr = &wpage_buf[0];
hs->dlen = AVB_WPAGE_LENGTH;
}
else if (strncmp(data, "POST /POWER", 11) == 0)
{
#if 1
printstrln("receive POST /POWER");
for(int i=0; i<len; i++)
printchar(data[i]);
#endif
...
}
...
//******************************************************************
1.firefox browser
(Request-Line):POST /POWER HTTP/1.1
User-Agent:Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)
Host:192.1.4.110
Content-Type:application/octet-stream
Content-Length:11
Accept:*/*
88390065 21
2.chrome browser
(Request-Line):POST /POWER HTTP/1.1
Accept-Language:zh-CN,zh;q=0.8
Host:192.1.4.110
User-Agent:Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64
Safari/537.31
Connection:keep-alive
Referer:...
Origin:...
Accept-Encoding:gzip,deflate,sdch
Accept-Charset:GBK,utf-8;q=0.7,*;q=0.3
Content-type:application/x-www-form-urlencoded
Content-Length:11
Accept:*/*
88390065 21
However, when I use IE browser to visit and click the web's buttom, it print only HTTP packet header as follows:
(Request-Line):POST /POWER HTTP/1.1
Host:192.1.4.110
Cookie:OUTFOX_SEARCH_USER_ID=-80099848@115.204.95.140
Cache-Control:no-cache
Connection:Keep-Alive
Content-Length:11
Accept:*/*
But it can not receive and print the valid data(88390065 21), I don't know why. Does any one can help me to anaylze this problem or give me some suggestion ? It seems that the tcp stack can not parse the IE browser's http packet, right ?
Tony