19 extern char homepage_default[];
20 char tx_buf[MAX_URI_SIZE];
21 char rx_buf[MAX_URI_SIZE];
34 for (x = 0; str[x]; x++)
35 if (str[x] == oldchar) str[x] = newchar;
47 if (c >=
'0' && c <=
'9')
49 if (c >=
'a' && c <=
'f')
51 if (c >=
'A' && c <=
'F')
66 for (x = 0, y = 0; url[y]; ++x, ++y) {
67 if ((url[x] = url[y]) ==
'%') {
68 url[x] =
C2D(url[y+1])*0x10+
C2D(url[y+2]);
90 if (type ==
PTYPE_HTML) head = RES_HTMLHEAD_OK;
91 else if (type ==
PTYPE_CGI) head = RES_HTMLHEAD_OK;
92 else if (type == PTYPE_PL) head = RES_HTMLHEAD_OK;
93 else if (type ==
PTYPE_GIF) head = RES_GIFHEAD_OK;
94 else if (type ==
PTYPE_TEXT) head = RES_TEXTHEAD_OK;
95 else if (type ==
PTYPE_JPEG) head = RES_JPEGHEAD_OK;
96 else if (type ==
PTYPE_FLASH) head = RES_FLASHHEAD_OK;
97 else if (type ==
PTYPE_MPEG) head = RES_MPEGHEAD_OK;
98 else if (type ==
PTYPE_PDF) head = RES_PDFHEAD_OK;
100 else PRINTLN(
"\r\n\r\n-MAKE HEAD UNKNOWN-\r\n");
103 sprintf(tmp,
"%ld", len);
104 strcpy((
char*)buf, head);
105 strcat((
char*)buf, tmp);
106 strcat((
char*)buf,
"\r\n\r\n");
119 if (strstr(buf,
".pl")) *type = PTYPE_PL;
120 else if (strstr(buf,
".cgi") || strstr(buf,
".CGI")) *type =
PTYPE_CGI;
121 else if (strstr(buf,
".html") || strstr(buf,
".htm")) *type =
PTYPE_HTML;
122 else if (strstr(buf,
".gif")) *type =
PTYPE_GIF;
123 else if (strstr(buf,
".text") || strstr(buf,
".txt")) *type =
PTYPE_TEXT;
124 else if (strstr(buf,
".jpeg") || strstr(buf,
".jpg")) *type =
PTYPE_JPEG;
126 else if (strstr(buf,
".mpeg") || strstr(buf,
".mpg")) *type =
PTYPE_MPEG;
127 else if (strstr(buf,
".pdf")) *type =
PTYPE_PDF;
128 else if (strstr(buf,
".js") || strstr(buf,
".JS")) *type =
PTYPE_TEXT;
129 else if (strstr(buf,
".xml") || strstr(buf,
".XML")) *type =
PTYPE_HTML;
138 st_http_request * request,
143 nexttok = strtok(buf,
" ");
149 if(!strcmp(nexttok,
"GET") || !strcmp(nexttok,
"get"))
152 nexttok = strtok(NULL,
" ");
154 PRINTLN(
"METHOD_GET");
157 else if (!strcmp(nexttok,
"HEAD") || !strcmp(nexttok,
"head"))
160 nexttok = strtok(NULL,
" ");
162 PRINTLN(
"METHOD_HEAD");
165 else if (!strcmp(nexttok,
"POST") || !strcmp(nexttok,
"post"))
167 nexttok = strtok(NULL,
" ");
170 PRINTLN(
"METHOD_POST");
177 PRINTLN(
"METHOD_ERR");
185 PRINTLN(
"METHOD_ERR");
190 strcpy(request->URI,nexttok);
191 nexttok = strtok(NULL,
"\0");
192 strcpy(request->param,nexttok);
197 printf(
"http_request->URI");
198 for(i=0; i < strlen(request->URI);i++)
199 printf(
"%c",request->URI[i]);
215 if(!uri || !param_name)
return 0;
216 if((name = strstr(uri,param_name)))
218 name += strlen(param_name) + 1;
219 char* pos2=strstr(name,
"&");
222 pos2=name+strlen(name);
230 strncpy((
char*)ret,name,len);
244 unsigned char* get_http_uri_name(
char* uri)
247 char* tempURI=(
char*)BUFPUB;
251 memset (tempURI, 0, MAX_URI_SIZE);
254 uri_name = strtok(tempURI,
" ?");
256 if(strcmp(uri_name,
"/")) uri_name++;
259 PRINTLN1(
"uri_name=%s",uri_name);
262 return (uint8*)uri_name;