473,387 Members | 1,492 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,387 software developers and data experts.

Headers - returning specified HTTP headers from a POST

I'm writing a service which accepts a POST call, updates a database and
returns raw HTTP headers as specified below:

HTTP/1.1 200 OK
Content-type:text/plain
Content-length:3

OK

The code runs, and returns my headers, but only after its own:

HTTP/1.1 100 Continue
Server: Microsoft-IIS/5.1
Date: Wed, 10 Aug 2005 21:45:58 GMT

HTTP/1.1 200 OK
Server: Microsoft-IIS/5.1
Date: Wed, 10 Aug 2005 21:45:58 GMT
Connection: close
Content-type:text/plain
Content-length:3

OK

Here's some static code which replicates the problem:

<?php
header( "HTTP/1.1 200 OK\r\n" );
header( "Content-type:text/plain\r\n" );
header( "Content-length:3\r\n" );
header( "\r\n" );
header( "OK \n" );
exit;
?>

The platform is IIS 5.1 (obviously) and we're using PHP 4.3.10.

If it can't be solved in PHP but can in Perl, ASP or some other language,
please let me know. Likewise if it can be solved on Apache/Linux/PHP 5. I
really didn't expect this to be a problem.

Thanks in advance. Did I mention that this is urgent?

Iain
Aug 11 '05 #1
1 2125
"John Smith" <jo*******@theweather.com.au> wrote:

Here's some static code which replicates the problem:

<?php
header( "HTTP/1.1 200 OK\r\n" );
header( "Content-type:text/plain\r\n" );
header( "Content-length:3\r\n" );
header( "\r\n" );
header( "OK \n" );
exit;
?>


Couple of problems. First, Apache will add the HTTP header, not you.
Next, each call to header() gets its own newline -- you don't provide it.
Next, "OK" is not a header, it is the body. This will do what you want:

===== cut here =====
<?php
header( "Content-type:text/plain" );
?>
OK
===== cut here =====
--
- Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Aug 11 '05 #2

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

Similar topics

2
by: Yannick Turgeon | last post by:
Hello all, My PHP script produce an intermittent CGI error. The sequence of events is: 1- User load page A to login 2- Submit page A redirect (with the PHP funciton header("Location:...
10
by: Lisa Pearlson | last post by:
Hi, I have a php script with no more than this: <?php echo "Hello World!"; ?> When a webbrowser client requests data, it receives Apache server headers, followed by my data: HTTP/1.1 200...
5
by: piotrek | last post by:
Hi I have a problem with http headers. Iam creating: private HttpWebRequest request = null; and: request = (HttpWebRequest)WebRequest.Create(server);
2
by: Iggy Evans | last post by:
Hi My app is trying to login to an ASP.NET site that uses Forms authentication. I am trying to do in my app (what was previously posted in a newsgroup) the same that a browser does 3) The browser...
0
by: CFloyd | last post by:
I have a web service client that sends an XML string to the web service for processing. I alos have to add some headers to the post. I first establish the baseuri as === baseuri = new...
2
by: Nathan Sokalski | last post by:
I have an ASP.NET application which displays the directories & files in a specified directory on the server. I use the System.IO.Directory.GetDirectories() and System.IO.Directory.GetFiles() to...
1
by: Max58kl | last post by:
Hi I am trying to setup a form that automatically sends the form values via email to a specific address. I have uploaded the script, which when I run loads a page with the following error...
0
by: Algobardo | last post by:
Good morning, this is the first time i write on this forum because i googled and i've seen related post with no solution. I will expose briefly the problem. I'm using c# 3.5 and i'm trying using...
6
Markus
by: Markus | last post by:
Things to discuss: Headers What are they? What does PHP have to do with headers? Why can they only be sent before any output? Common causes
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.