forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

bad request from http request of PSP, why.....

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
ldqmoon



Joined: 04 Dec 2007
Posts: 13

PostPosted: Sun Jun 15, 2008 11:34 am    Post subject: bad request from http request of PSP, why..... Reply with quote

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
View user's profile Send private message
Insert_witty_name



Joined: 10 May 2006
Posts: 376

PostPosted: Sun Jun 15, 2008 11:39 am    Post subject: Reply with quote

I get the same result in my computer browser for that IP...
Back to top
View user's profile Send private message
ldqmoon



Joined: 04 Dec 2007
Posts: 13

PostPosted: Sun Jun 15, 2008 4:47 pm    Post subject: Reply with quote

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
View user's profile Send private message
adrahil



Joined: 16 Mar 2006
Posts: 277

PostPosted: Sun Jun 22, 2008 10:14 pm    Post subject: Reply with quote

Strangely enough changing "GET /index.html http/1.1" to "GET /index.html HTTP/1.1" works for me...
Back to top
View user's profile Send private message
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Sat Jun 28, 2008 12:59 am    Post subject: Reply with quote

You'd best stick to following protocols down to the last (capital) letter.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group