| View previous topic :: View next topic |
| Author |
Message |
ldqmoon
Joined: 04 Dec 2007 Posts: 13
|
Posted: Sun Jun 15, 2008 11:34 am Post subject: bad request from http request of PSP, why..... |
|
|
I use the code next on PSP to get a page from internet. but it alway reture "400 bad request". I don't know why, it can work well on PC.
of cause, I had connected to the wifi.
Thanks for your suggestion.
| Code: | int http(void)
{
// http request
char Cmd[512]="GET /index.html http/1.1\r\n\
Host:www.acgclub.com\r\n\
Accept:*/*\r\n\
User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt; DTS Agent;)\r\n\
Connection:Keep-Alive\r\nCache-Control: no-cache\r\n\r\n";
int HTTPSocket; // http socket
struct sockaddr_in BindSocket;
char temp[512];
int bReturn;
// socket
pspprintf(" create socket\n");
HTTPSocket=socket(PF_INET, SOCK_STREAM, 0);
if(HTTPSocket < 0)
{
pspprintf("Error when socket");
return 0;
}
//
BindSocket.sin_addr.s_addr = inet_addr ("61.152.94.145"); // www.acgclub.com
BindSocket.sin_family=AF_INET;
BindSocket.sin_port=htons(80);
//
pspprintf("connect\n");
if (connect(HTTPSocket, (struct sockaddr *)&BindSocket, sizeof(BindSocket))<0)
{
close(HTTPSocket);
pspprintf("connect failed");
return 0;
}
//送http request
pspprintf("%s", Cmd);
pspprintf("\n\n");
if(send(HTTPSocket, Cmd, strlen(Cmd), 0) <0)
{
close(HTTPSocket);
pspprintf("send http header request failed\n");
return 0;
}
pspprintf("http header\n");
///get http http header
bReturn=GetHttpHeader(HTTPSocket,temp);
if(!bReturn)
{
close(HTTPSocket);
pspprintf("get http header failed\n");
return 0;
}
pspprintf("ok\n");
pspprintf("%s", temp);
close(HTTPSocket);
return 1;
} |
|
|
| Back to top |
|
 |
Insert_witty_name
Joined: 10 May 2006 Posts: 376
|
Posted: Sun Jun 15, 2008 11:39 am Post subject: |
|
|
| I get the same result in my computer browser for that IP... |
|
| Back to top |
|
 |
ldqmoon
Joined: 04 Dec 2007 Posts: 13
|
Posted: Sun Jun 15, 2008 4:47 pm Post subject: |
|
|
oh... it's a Chinese IP, I don't know if it can be open in other country.
But even if I change to another URL, it also get "bad request" . |
|
| Back to top |
|
 |
adrahil
Joined: 16 Mar 2006 Posts: 277
|
Posted: Sun Jun 22, 2008 10:14 pm Post subject: |
|
|
| Strangely enough changing "GET /index.html http/1.1" to "GET /index.html HTTP/1.1" works for me... |
|
| Back to top |
|
 |
Torch

Joined: 28 May 2008 Posts: 842
|
Posted: Sat Jun 28, 2008 12:59 am Post subject: |
|
|
| You'd best stick to following protocols down to the last (capital) letter. |
|
| Back to top |
|
 |
|