Connecting Tech Pros Worldwide Help | Site Map

Get HTTP Response Code

  #1  
Old November 12th, 2005, 12:45 AM
Mazin07
Guest
 
Posts: n/a
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.
  #2  
Old November 22nd, 2005, 12:05 AM
Oli Filth
Guest
 
Posts: n/a

re: Get HTTP Response Code


Mazin07 said the following on 12/11/2005 00:20:[color=blue]
> Is there any way to get the HTTP Response Code sent out by the server
> (ie 404, 302, etc)?[/color]

?

If your script runs, then it is up to the script to determine the
response code. By default, it's 200 (OK).
[color=blue]
> Or could I just assume that the same code was sent?[/color]

Same as what?
[color=blue]
> I know the $_SERVER array has a lot of info, but this isn't in there.[/color]

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
  #3  
Old November 22nd, 2005, 12:05 AM
kicken
Guest
 
Posts: n/a

re: Get HTTP Response Code


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.
  #4  
Old November 22nd, 2005, 12:05 AM
Steve
Guest
 
Posts: n/a

re: Get HTTP Response Code


In article <zzadf.5300$Lv.1907@newssvr23.news.prodigy.net>,
mazin07@gmail.com (Mazin07) wrote:
[color=blue]
> *Subject:* Get HTTP Response Code
> *From:* Mazin07 <mazin07@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.
>[/color]
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
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Get http response codes Bart op de grote markt answers 4 November 2nd, 2006 04:25 AM
Getting the HTTP response code that is sent via a cell phone jl answers 2 September 9th, 2006 03:15 AM
Problem writing bitmap image to HTTP response stream. answers 2 November 18th, 2005 05:22 PM
Retrieving HTTP Response Code Chris Fink answers 4 November 17th, 2005 12:38 AM