473,670 Members | 2,624 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

sending http post requests

i'm trying to send an http post request and see if the server got it
correctly. i'm sending the http post request with this script:

<?
$address = 'domain.tld';
$port = 80;

$proxy = fsockopen("tcp://$address", (int) $port, $errno, $errstr, 1);

$extra = "extra=blah&thi s=test";

fputs($proxy,"P OST /test.php HTTP/1.0\r\n");
fputs($proxy,"H ost: $address\r\n");
fputs($proxy,"C ontent-Length: ".strlen($extra )."\r\n\r\n") ;
fputs($proxy,"$ extra\r\n");

while (!feof($proxy))
print fgets($proxy);
fclose($proxy);
?>

test.php's contents are as follows:

<?
print_r($_POST) ;
?>

this is what i want to see:

Array
(
[extra] => blah
[this] => test
)

this is what i am seeing:

Array
(
)

any ideas as to what i'm doing wrong and how i can fix it? thanks!

Jul 17 '05 #1
2 2765
yawnmoth wrote:
i'm trying to send an http post request and see if the server got it
correctly. i'm sending the http post request with this script:

My script looks almost exactly the same (but works ;). A couple of
suggestions:
<?
$address = 'domain.tld';
$port = 80;

$proxy = fsockopen("tcp://$address", (int) $port, $errno, $errstr, 1);

Timeout seems a bit short - but OK for testing locally. The 'tcp://' was new
to me - according to the manual it's valid. Might be worth trying without.
$extra = "extra=blah&thi s=test";

fputs($proxy,"P OST /test.php HTTP/1.0\r\n");
fputs($proxy,"H ost: $address\r\n");
** maybe add : "Content-type: application/x-www-form-urlencoded\r\n" ;
fputs($proxy,"C ontent-Length: ".strlen($extra )."\r\n\r\n") ;
fputs($proxy,"$ extra\r\n");


literal paste from my script:
$p.="Content-length: $len\n\n";
$p.= "$str\n";
$p.= "\r\n";

It was kind of a long tiime ago I wrote it, and can't recall why the first
two lines didn't get a '\r'.

HTH

C.
Jul 17 '05 #2

Colin McKinnon wrote:
yawnmoth wrote:
$extra = "extra=blah&thi s=test";

fputs($proxy,"P OST /test.php HTTP/1.0\r\n");
fputs($proxy,"H ost: $address\r\n");


** maybe add : "Content-type: application/x-www-form-urlencoded\r\n" ;


That fixed it - thanks! :)

Jul 17 '05 #3

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

Similar topics

5
3228
by: PerryG | last post by:
We have a .NET 1.1 client which is sending a gzipped soap request using HttpWebRequest to an Apache server. The Apache server is using a the 'mod_deflate' server to decompress the incoming message, and to also compress the response (GZIP). The mod_deflate filter requires the 'Content-Length' header contained within the incoming request to specify the number of UNCOMPRESSED bytes being sent and not the actual bytes of the body of the...
20
2481
by: CHIN | last post by:
Hi all.. here s my problem ( maybe some of you saw me on other groups, but i cant find the solution !! ) I have to upload a file to an external site, so, i made a .vbs file , that logins to the site, and then i have to select the file to upload.. i used sendkeys.. and i worked perfect.. BUT ... the computer must be locked for security ( obviusly ) reazons.. so..i think this probable solutions to unlock the computer and run the...
1
2228
by: Dhwanil Shah | last post by:
Hi, We have an aspx page designed in VS.NET 2003. Our requirement is that a client (another application), sends HEAD requests to our application with Basic Auth header. Based on security criteria, we need to "tell" the other application whether the user is allowed to use that page or not. Another criteria is that if a specific user comes to this page then the entire content of that page should be displayed to him / her. The calling...
4
12138
by: yawnmoth | last post by:
Is it possible to send http requests with curl but not have curl wait for the response? The reason I ask is because I'd like to code a web app that can sorta start time consuming processes without the user having to wait. I'm doing this (with fsockopen) by sending an http request to a page that does the time consuming stuff and then immediatly closing, without having read any of the response. This way, I don't have to wait for the...
0
8468
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8386
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8901
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7415
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6213
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5683
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4209
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2799
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1792
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.