473,396 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

getting bad results from fsocketopen

If I send this to the server:

POST /errors/index.htm HTTP/1.1
Host: www.publicdomainsoftware.org
Content-Type: application/x-www-form-urlencoded
Content-Length: 1200
%3C%2Fdiv%3E

Why do I get this back:

HTTP/1.1 400 Bad Request Date: Fri, 12 May 2006 02:37:43 GMT Server:
Apache/2.0.46 (Red Hat) Content-Length: 302 Connection: close
Content-Type: text/html; charset=iso-8859-1
Bad Request
Your browser sent a request that this server could not understand.
Apache/2.0.46 (Red Hat) Server at default Port 80

May 12 '06 #1
5 3287
lawrence k wrote:
If I send this to the server:

POST /errors/index.htm HTTP/1.1
Host: www.publicdomainsoftware.org
Content-Type: application/x-www-form-urlencoded
Content-Length: 1200
%3C%2Fdiv%3E


Try this, instead:

POST /errors/index.htm HTTP/1.1
Host: www.publicdomainsoftware.org
Content-Type: application/x-www-form-urlencoded
Content-Length: 1200
Connection: close

%3C%2Fdiv%3E

Note how there are two new lines between the last HTTP header and the
actual data. Also... the Content-Length field doesn't look correct.
strlen(urldecode('%3C%2Fdiv%3E')) is definitly not 1200...

May 12 '06 #2

yawnmoth wrote:
Try this, instead:

POST /errors/index.htm HTTP/1.1
Host: www.publicdomainsoftware.org
Content-Type: application/x-www-form-urlencoded
Content-Length: 1200
Connection: close

%3C%2Fdiv%3E

Note how there are two new lines between the last HTTP header and the
actual data. Also... the Content-Length field doesn't look correct.
strlen(urldecode('%3C%2Fdiv%3E')) is definitly not 1200...


Thanks much. That did the trick.

May 12 '06 #3

yawnmoth wrote:
Try this, instead:

POST /errors/index.htm HTTP/1.1
Host: www.publicdomainsoftware.org
Content-Type: application/x-www-form-urlencoded
Content-Length: 1200
Connection: close

%3C%2Fdiv%3E

Note how there are two new lines between the last HTTP header and the
actual data. Also... the Content-Length field doesn't look correct.
strlen(urldecode('%3C%2Fdiv%3E')) is definitly not 1200...

It's curious, but fsocketopen takes forever. It's basically unuseable
for me. It brings the site to a standstill. My code is taken straight
from an example on www.php.net:

$message = rawurlencode($message);
$message = "&errorInput=$message";
$length = strlen($message);

$fp = fsockopen("www.publicdomainsoftware.org", 80, $errno, $errstr,
30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
$out = "POST /errors/errorInput.php HTTP/1.1\r\n";
$out .= "Host: www.publicdomainsoftware.org\r\n";
$out .= "Content-Type: application/x-www-form-urlencoded\r\n";
$out .= "Content-Length: $length\r\n";
$out .= "Connection: Close\r\n\r\n";
$out .= "$message";

fwrite($fp, $out);
while (!feof($fp)) {
// echo fgets($fp, 128);
}
fclose($fp);
}

The variable $message is just the parameter being passed in. This code
can take 4 or 5 minutes to work, and then finally the pages, often,
just time out.

Any idea why that might be?

May 12 '06 #4

lawrence k wrote:
<snip>
It's curious, but fsocketopen takes forever. It's basically unuseable
for me. It brings the site to a standstill. My code is taken straight
from an example on www.php.net:

<snip>

while (!feof($fp)) {
// echo fgets($fp, 128);
}
fclose($fp);
}

The file pointer never gets to the end of the file because its never
incremented. As such, try uncommenting out the fgets.

May 12 '06 #5

yawnmoth wrote:
lawrence k wrote:
<snip>
It's curious, but fsocketopen takes forever. It's basically unuseable
for me. It brings the site to a standstill. My code is taken straight
from an example on www.php.net:

<snip>

while (!feof($fp)) {
// echo fgets($fp, 128);
}
fclose($fp);
}

The file pointer never gets to the end of the file because its never
incremented. As such, try uncommenting out the fgets.


Thanks a million for catching that. You saved the day again.

May 12 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: gregpinero | last post by:
Hey everyone, I'm trying to call a system command "svnlook log \arms" from within python and process the results. However I'm having trouble getting the results of the command back into python....
0
by: Golawala, Moiz M (GE Infrastructure) | last post by:
Hi All, Could someone please help me with an issue I am having. I am having problem returning values from a Stored Procedure that creates a dynamic table (table variable) inserts values during a...
4
by: s99999999s2003 | last post by:
hi the database "execute" function returns a list of logical results. Each logical result is a list of row tuples, as explained in the documents. everytime i use it to execute various...
4
by: Sondra Wilson | last post by:
I have created a sorted query. The total(records) I get in the query is correct. My problem lies with getting that total into my report. I use count to insert the total number of records in my...
4
by: Mike Dinnis | last post by:
Hi, I've been working through a number of turorials to try to learn more about retrieving data from a SQL database. I think i've mastered techniques where i create a sql string in the page and...
3
by: D. Shane Fowlkes | last post by:
(still a .NET newbie) I have a chunk of code in a Page_Load routine that pulls data from a SQL Server table. The Select statement looks for any "events" scheduled for today. Then my IF...
1
by: Michael Jean | last post by:
hello, i am building some objects to keep track of page statistics (ie, pages visited by certain ip addresses) so that i can see which countries my visitors are coming from. i am using a free...
10
by: Peter Afonin | last post by:
Hello, I have a simple client-side form that is checking the domain availability on the domain registrar's server: <FORM action="https://www.webnames.ru/scripts/RegTimeSRS.pl" method="post">...
9
by: christopher_board | last post by:
Hi all. I am trying to write a php page which connects to a MySQL Database which is supposed to get the results from a table within a database and display the results in a table. Below is the...
2
by: sandeepk84 | last post by:
Hi all, I have an sql to retrieve some data. the format of the query is like, select field1,field2 from tablename where field1 in(1,2,3); This is fine and it returns the details correctly. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.