473,404 Members | 2,179 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,404 software developers and data experts.

Get HTTP Response Code

Is there any way to get the HTTP Response Code sent out by the server
(ie 404, 302, etc)?

Or could I just assume that the same code was sent?

I know the $_SERVER array has a lot of info, but this isn't in there.

I'm trying to create my own text logs here.
Nov 12 '05 #1
3 3762
Mazin07 said the following on 12/11/2005 00:20:
Is there any way to get the HTTP Response Code sent out by the server
(ie 404, 302, etc)?
?

If your script runs, then it is up to the script to determine the
response code. By default, it's 200 (OK).
Or could I just assume that the same code was sent?
Same as what?
I know the $_SERVER array has a lot of info, but this isn't in there.


Well, obviously! Whilst the script is running, a response hasn't been
sent, so how could the response possibly be stored in a pre-defined
variable?
--
Oli
Nov 22 '05 #2
If you're talking about the response code that is returned with the
output of your script, then it will be 200 unless you change it using a
header() call. If you do a header('Location:') redirect then it changes
to 302 I think.

The other possibility that it would be different is if you're using the
PHP script as an ErrorDocument handler. If that's the case, I think you
can just pass it as a parameter when you setup the error handler.
Nov 22 '05 #3
In article <zz****************@newssvr23.news.prodigy.net>,
ma*****@gmail.com (Mazin07) wrote:
*Subject:* Get HTTP Response Code
*From:* Mazin07 <ma*****@gmail.com>
*Date:* Sat, 12 Nov 2005 00:20:47 GMT

Is there any way to get the HTTP Response Code sent out by the server
(ie 404, 302, etc)?

Or could I just assume that the same code was sent?

I know the $_SERVER array has a lot of info, but this isn't in there.

I'm trying to create my own text logs here.

I have a little script running in my custom error pages. 404.php,
403.php and 500.php.

If you can have custom error pages then you could do the same. I save
the IP, date, time, and referring page. That way, I get an idea of what
is broken or what was being attempted. (Usually virus activity which of
course has no referer.)

It just saves me going through the main site logs.

500 : 128:Sun, 13 Nov 2005 11:19:18 +0000:211.20.54.196:211.20.54.196 :

gives me error code, how many times that code has been hit, date - time,
IP, and gethostbyaddr obviously didn't resolve.

A quick look at the main log shows it was a virus attack.
211.20.54.196 - - [13/Nov/2005:11:19:15 +0000] "GET
//cgi-bin/awstats/awstats.pl HTTP/1.1" 500 659 "" "Mozilla/4.0
(compatible; MSIE 6.0; Windows 98)"
Is that what you meant ???
- Steve
Nov 22 '05 #4

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

Similar topics

7
by: Michael Foord | last post by:
#!/usr/bin/python -u # 15-09-04 # v1.0.0 # auth_example.py # A simple script manually demonstrating basic authentication. # Copyright Michael Foord # Free to use, modify and relicense. #...
0
by: jacob c. | last post by:
When I request a URL using urllib2, it appears that urllib2 always makes the request using HTTP 1.0, and not HTTP 1.1. I'm trying to use the "If-None-Match"/"ETag" HTTP headers to conserve...
3
by: Derrick | last post by:
I have an http download that streams a zip file to client, after download I am getting "Error start of central directory not found; Zip file corrupt. Possible casue: file transfer error." Ring...
6
by: A.M-SG | last post by:
Hi, I have an aspx page at the web server that provides PDF documents for smart client applications. Here is the code in aspx page that defines content type: Response.ContentType =...
8
by: Andreas Klemt | last post by:
Hello, I get this error Message "cannot redirect after http headers have been sent" when I do this response.redirect ("home.aspx") How can I find out with vb.net if already a http header has...
2
by: | last post by:
Hello All, I am writing a web application that reads a bitmap from a file and outputing it to a HTTP response stream to return the image to the requesting client. The image file is a regular...
5
by: David Lozzi | last post by:
Howdy, I wrote a web service in .Net for my customer. My customer has another vendor who now has to consume it but they are not using Visual Studio. Most of their pages are jsp, and they said...
4
by: Bob Badger | last post by:
Hi, Simple question (although I guess with a complicated answer). Is HTTP an async protocol? For instance, if I send a message to a c# webservice via http what is the protocol actually doing? ...
2
by: MDANH2002 | last post by:
Hi From VB.NET I want to simulate the POST request of the following HTML form <html> <title>HTTP Post Testing</title> <body> <form action=http://www.example.com/postdata ...
7
by: Guy Davidson | last post by:
Hi Folks, I'm having some issues with an small socket based server I'm writing, and I was hoping I could get some help. My code (attached below) us supposed to read an HTTP Post message...
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
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
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...

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.