Re: [PHP] Show the entire browser request
2009/6/10 Robin Vickery > > > 2009/6/10 Dotan Cohen > >> > Just checked your site in Elinks (works like Lynx) and I'm getting the >> > headers come back to me. I'm assuming you changed your site code before >> > me sending this and after you sent the original message? >> > >> >> The individual headers are as they always were. It's the entire >> request verbatim (valid or not) that I'd like to add. >> > > Is installing the pecl_http extension on your server an option? > > http://php.net/manual/en/function.httprequest-getrawrequestmessage.php > Oh.. ignore that, sorry. I'm an idiot. -robin
Re: [PHP] Show the entire browser request
2009/6/10 Dotan Cohen > > Just checked your site in Elinks (works like Lynx) and I'm getting the > > headers come back to me. I'm assuming you changed your site code before > > me sending this and after you sent the original message? > > > > The individual headers are as they always were. It's the entire > request verbatim (valid or not) that I'd like to add. > Is installing the pecl_http extension on your server an option? http://php.net/manual/en/function.httprequest-getrawrequestmessage.php -robin
Re: [PHP] Show the entire browser request
> Just checked your site in Elinks (works like Lynx) and I'm getting the > headers come back to me. I'm assuming you changed your site code before > me sending this and after you sent the original message? > The individual headers are as they always were. It's the entire request verbatim (valid or not) that I'd like to add. -- Dotan Cohen http://what-is-what.com http://gibberish.co.il -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Show the entire browser request
On Tue, 2009-06-09 at 17:58 +0300, Dotan Cohen wrote: > > There are no risks that I can see in the code. You're welcome to use > > it, and a link to http://stut.net/ is always appreciated ;-) > > > > In August when I will have more time to devote to it I will put it on > the site. With link, and it is _me_ who appreciates _your_ help. > Thanks! > > Dotan Cohen > > http://what-is-what.com > http://gibberish.co.il > Just checked your site in Elinks (works like Lynx) and I'm getting the headers come back to me. I'm assuming you changed your site code before me sending this and after you sent the original message? Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Show the entire browser request
> There are no risks that I can see in the code. You're welcome to use > it, and a link to http://stut.net/ is always appreciated ;-) > In August when I will have more time to devote to it I will put it on the site. With link, and it is _me_ who appreciates _your_ help. Thanks! Dotan Cohen http://what-is-what.com http://gibberish.co.il -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Show the entire browser request
2009/6/9 Dotan Cohen : > Why should this be run on port 8000? Is there a security implication > of running this on port 80? Would it be unwise to use this as a public > service, for instance? You can run it on port 80 but you'll need to make sure there's not another web server running on that port and you'll probably need to run it as an admin user. > I was considering adding the tool to http://simplesniff, which is why > I ask. Of course, that would only be with your permission, and it > would give you credit for writing the code as well. There are no risks that I can see in the code. You're welcome to use it, and a link to http://stut.net/ is always appreciated ;-) If you're running it on a server that already has a web server on port 80 you have 2 choices... 1) Run it on another port. 2) Bind it to a different IP address. Option 1 is the simplest and wasting an IP for just this is a bit daft IMHO. One thing to note is that it can only handle a single request at once. If you want it to handle more simultaneously it'll need modifying a bit. Another way to go about this would be to run it using xinetd, but be sure to remove the while(true) loop before you do that, and close the $s socket at the end of the script. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Show the entire browser request
Why should this be run on port 8000? Is there a security implication of running this on port 80? Would it be unwise to use this as a public service, for instance? I was considering adding the tool to http://simplesniff, which is why I ask. Of course, that would only be with your permission, and it would give you credit for writing the code as well. -- Dotan Cohen http://what-is-what.com http://gibberish.co.il -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Show the entire browser request
> Run this on a command line and hit the IP on port 8000. All it does is > read the request and send it back as the response. It ignores POST > bodies but it would be pretty simple to modify it so it echo's those > back too. > > http://dev.stut.net/php/httpsrv.phps > Stuart, that is quite a bit of work! Nice! I also learned some really nice tips here, such as your usage of define for the header and footer, and why that is the cleanest solution when you need the content-length. The usage of sockets is new to me too, but this was easy to follow. Thanks! -- Dotan Cohen http://what-is-what.com http://gibberish.co.il -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Show the entire browser request
2009/6/8 Dotan Cohen : >> If its the request from the browser, why not just fire up a packet sniffer >> and get it that way? Unless it's using SSL/TLS/VPN/something that would >> encrypt it, you should be able to see the request in clear text. >> > > The browser is running on a Symbian cellphone. Run this on a command line and hit the IP on port 8000. All it does is read the request and send it back as the response. It ignores POST bodies but it would be pretty simple to modify it so it echo's those back too. http://dev.stut.net/php/httpsrv.phps -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Show the entire browser request
> If its the request from the browser, why not just fire up a packet sniffer > and get it that way? Unless it's using SSL/TLS/VPN/something that would > encrypt it, you should be able to see the request in clear text. > The browser is running on a Symbian cellphone. -- Dotan Cohen http://what-is-what.com http://gibberish.co.il -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Show the entire browser request
On Mon, Jun 8, 2009 at 4:40 PM, Dotan Cohen wrote: >> This should do it, I believe: >> >> > >> echo $_SERVER['REQUEST_METHOD'], ' ', $_SERVER['REQUEST_URI'], ' ', >> $_SERVER['SERVER_PROTOCOL']; >> >> ?> >> > > Thanks, Andrew, I'm sure that works for correctly-formed requests. > However, I am trying to diagnose a web browser that is _not_ correctly > forming it's requests, therefore I need the real request itself, as it > was. > > I am starting to realize that PHP is not the language for this, I may > have to look into an Apache module or something lower-level. Thanks! > > -- > Dotan Cohen > > http://what-is-what.com > http://gibberish.co.il > I think you're probably correct. I would imagine the request has to be at least well formed enough for the $_SERVER variables to be populated in order for it to even get into PHP. Otherwise, the web server wouldn't know what to do with it. The request method itself would have to be something that PHP is told to handle (which from what I've seen is usually only GET, POST or PUT, though other methods could be configure); if the request_uri is messed up, it will generally result in a 404 because the resource can't be found rather than a BAD REQUEST response. I'm not sure what impact the protocol part of that line has. For what you want, you probably need to write your own socket server to listen for the request and echo it back to the client. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Show the entire browser request
If its the request from the browser, why not just fire up a packet sniffer and get it that way? Unless it's using SSL/TLS/VPN/something that would encrypt it, you should be able to see the request in clear text. On Mon, Jun 8, 2009 at 4:40 PM, Dotan Cohen wrote: > > This should do it, I believe: > > > > > > > echo $_SERVER['REQUEST_METHOD'], ' ', $_SERVER['REQUEST_URI'], ' ', > > $_SERVER['SERVER_PROTOCOL']; > > > > ?> > > > > Thanks, Andrew, I'm sure that works for correctly-formed requests. > However, I am trying to diagnose a web browser that is _not_ correctly > forming it's requests, therefore I need the real request itself, as it > was. > > I am starting to realize that PHP is not the language for this, I may > have to look into an Apache module or something lower-level. Thanks! > > -- > Dotan Cohen > > http://what-is-what.com > http://gibberish.co.il > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: [PHP] Show the entire browser request
> This should do it, I believe: > > > echo $_SERVER['REQUEST_METHOD'], ' ', $_SERVER['REQUEST_URI'], ' ', > $_SERVER['SERVER_PROTOCOL']; > > ?> > Thanks, Andrew, I'm sure that works for correctly-formed requests. However, I am trying to diagnose a web browser that is _not_ correctly forming it's requests, therefore I need the real request itself, as it was. I am starting to realize that PHP is not the language for this, I may have to look into an Apache module or something lower-level. Thanks! -- Dotan Cohen http://what-is-what.com http://gibberish.co.il -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Show the entire browser request
On Mon, Jun 8, 2009 at 2:40 PM, Dotan Cohen wrote: >> Roger that. Check out getallheaders() then: >> >> http://php.net/getallheaders >> > > Well, that seems to be partway there, but it doesn't include the GET request. > > -- > Dotan Cohen > > http://what-is-what.com > http://gibberish.co.il > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > This should do it, I believe: -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Show the entire browser request
> Roger that. Check out getallheaders() then: > > http://php.net/getallheaders > Well, that seems to be partway there, but it doesn't include the GET request. -- Dotan Cohen http://what-is-what.com http://gibberish.co.il -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Show the entire browser request
On Mon, Jun 8, 2009 at 12:17, Dotan Cohen wrote: > > Thanks, Daniel, but I am trying to help someone who is writing a > text-based web browser but gets "Bad Request" messages from some > websites. As he is able to visit http://simplesniff.com (my site) I > figured that it would help if I could just reply back with a page that > contained the exact request that he made. Roger that. Check out getallheaders() then: http://php.net/getallheaders -- daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ 50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Show the entire browser request
On Mon, Jun 8, 2009 at 12:07, Dotan Cohen wrote: > I need to diagnose a web browser problem, and I'd like PHP to return a > page that shows the entire browser request, exactly as it was sent. It > would naturally contain all the data in the HTTP Headers Information > from phpinfo() but formatted exactly as the browser sent it. Depending on the specifics of the problem at hand, Dotan, you may actually be better-served by running the diagnostics locally using LiveHTTPHeaders[1] (a Firefox addon) or something similar. ^1: http://livehttpheaders.mozdev.org/ -- daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ 50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Show the entire browser request
Hi, > I need to diagnose a web browser problem, and I'd like PHP to return a > page that shows the entire browser request, exactly as it was sent. It > would naturally contain all the data in the HTTP Headers Information > from phpinfo() but formatted exactly as the browser sent it. Sounds like what you really want is Fiddler (MSIE, http://www.fiddlertool.com) or Firebug (Firefox, http://getfirebug.com/). The latter is indispensable. -- Richard Heyes HTML5 graphing: RGraph (www.rgraph.net - updated 6th June) PHP mail: RMail (www.phpguru.org/rmail) PHP datagrid: RGrid (www.phpguru.org/rgrid) PHP Template: RTemplate (www.phpguru.org/rtemplate) PHP SMTP: http://www.phpguru.org/smtp -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Show the entire browser request
>> I need to diagnose a web browser problem, and I'd like PHP to return a >> page that shows the entire browser request, exactly as it was sent. It >> would naturally contain all the data in the HTTP Headers Information >> from phpinfo() but formatted exactly as the browser sent it. > > Depending on the specifics of the problem at hand, Dotan, you may > actually be better-served by running the diagnostics locally using > LiveHTTPHeaders[1] (a Firefox addon) or something similar. > > ^1: http://livehttpheaders.mozdev.org/ > Thanks, Daniel, but I am trying to help someone who is writing a text-based web browser but gets "Bad Request" messages from some websites. As he is able to visit http://simplesniff.com (my site) I figured that it would help if I could just reply back with a page that contained the exact request that he made. -- Dotan Cohen http://what-is-what.com http://gibberish.co.il -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php