Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old November 12th, 2005, 12:45 AM
Mazin07
Guest
 
Posts: n/a
Default 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.
  #2  
Old November 22nd, 2005, 12:05 AM
Oli Filth
Guest
 
Posts: n/a
Default 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
Default 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
Default 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
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles