Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTTP/1.1 400 Bad Request when trying to send to cgi file

Status
Not open for further replies.

mmills1

Programmer
Apr 8, 2010
18
GB
I have a device which is automatically sending a cgi file to my server.

In wireshark I can see the data being sent to the server but apache is responding with a HTTP/1.1 400 Bad Request,

I have tried writing several different get and post headers to get an ok response from apache but have not been successful? Help??

 

What the client sent send:

GET /htdocs/index.php HTTP/1.1 \r\n Host:6.52.9.177 \r\n Connection: close \r\n\r\n


the response:

HTTP/1.1 400 Bad Request

Date: Thu, 08 Apr 2010 13:08:07 GMT

Server: Apache/2.0.53 (Linux/SUSE)

Content-Length: 304

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>
<hr>
<address>Apache/2.0.53 (Linux/SUSE) Server at bergman2 Port 80</address>
</body></html>



I have change the carriage returns to CRLF, \r\n, \n, [CRLF], but still stays on same line, if this is the problem?
 

What the client sent:

GET /htdocs/index.php HTTP/1.1 \r\n Host:6.52.9.177 \r\n Connection: close \r\n\r\n


the response:

HTTP/1.1 400 Bad Request

Date: Thu, 08 Apr 2010 13:08:07 GMT

Server: Apache/2.0.53 (Linux/SUSE)

Content-Length: 304

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>
<hr>
<address>Apache/2.0.53 (Linux/SUSE) Server at bergman2 Port 80</address>
</body></html>



I have change the carriage returns to CRLF, \r\n, \n, [CRLF], but still stays on same line, if this is the problem?
 
Hi

mmills1 said:
I have change the carriage returns to CRLF, \r\n, \n, [CRLF], but still stays on same line, if this is the problem?
Yes, most probably that is the problem. In which case, this is not really an Apache issue.

But for now you can post your code which makes the request here, so we can suggest correction.

Feherke.
 
Ok, cheers,

below is the cgi file which i want to send so that I can pick it up again on the server side:

POST /htdocs/client.cgi HTTP/1.1 \r\n
UserAgent:HTTPTool /1.0 \r\n
Content-Type: application/x- \r\n
Content-Length:32 \r\n

Learning as I go with the headers does this look correct??


Cheers for your help
 
That is what i was using, to get a connection? Have not written any code yet as I will be able to see with wireshark when it is accepted??

I guess I am on the wrong track??
 
#!/usr/bin/perl
use Fcntl; #The Module

print "content-type: text/html \n\n"; #The header
sysopen (HTML, '/home/httpd/htdocs/myhtml.html', O_RDWR|O_EXCL|O_CREAT, 0755);
printf HTML "<html>\n";
printf HTML "<head>\n";
printf HTML "<title>My Home Page</title>";
printf HTML "</head>\n";
printf HTML "<body>\n";
printf HTML "<p align='center'>Here we have an HTML
page with a paragraph.</p>";
printf HTML "</body>\n";
printf HTML "</html>\n";
close (HTML);

~

We the code above I am trying to create and write to a file on the server but still get same error?
 
Hi

I suppose, that is your CGI script. It has nothing to do with the bad or any kind of request.
Feherke said:
post your code which makes the request
mmills1 said:
What the client sent:

GET /htdocs/index.php HTTP/1.1 \r\n Host:6.52.9.177 \r\n Connection: close \r\n\r\n
What kind of client is sending that ?

Feherke.
 
It is a device which sends a client.cgi file to the server on port 80. Thats all I have?

The client.cgi file will contain details of inputs and outputs on the device. So if i can get these to write to a file on the server i can then use PHP to manipulate the data.

So do not know why I am getting the bad request, just know I somehow need to get the apache server to like the client.cgi file coming from the device(client). I thought I could just write headers for apache to read in the client.cgi file but obviously not that would be to simple??

What would you suggest??
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top