views:

113

answers:

8

I need to see exactly what the browser sends to a form, for debugging purposes. I have the "tamper data" addon for Mozilla, but it doesn't show me what I am looking for. What I need is a text file with all that the browser sends, it should look like this:

Content-Type: multipart/form-data; boundary=AaB03x

   --AaB03x
   Content-Disposition: form-data; name="submit-name"

   Larry
   --AaB03x
   Content-Disposition: form-data; name="files"
   Content-Type: multipart/mixed; boundary=BbC04y

   --BbC04y
   Content-Disposition: file; filename="file1.txt"
   Content-Type: text/plain
A: 

There are a few methods, but it depends on your software. If your using Apache, you can look at the following:

apache_request_headers() 

getallheaders() 

apache_response_headers()

for figuring out what you are going to send back.

I believe that all of those links above require that apache be configured as a module, and not as a cgi. You can check your current settings if you are unsure by using your phpinfo() and seeking Server API. If it says CGI, your out of luck on these functions.

There are however additional variables that you can use if your looking at the CGI installation. These exist both with the module and the CGI/CLI API's btw, and are all children of the $_ENV/$HTTP_ENV_VARS (envirornmental) superglobal:

HTTP_ACCEPT

HTTP_ACCEPT_ENCODING

HTTP_ACCEPT_LANGUAGE

HTTP_CONNECTION

HTTP_USER_AGENT

HTTP_REDIRECT_STATUS

HTTP_REMOTE_ADDR

HTTP_REMOTE_PORT

SERVER_PROTOCOL

and REQUEST_METHOD

You may have more depending on your configurations, but chances are these are containing all the information you are looking for. If your php version is >= 5.0.0, you can also use get_headers() which I believe is API independant.

Hope that helps!

For more information please check,

http://www.codingforums.com/archive/index.php/t-69186.html

Yogesh
Could you repost the relevant parts of that thread here? SO was created so you *don't* have to wade through endless badly formatted forum discussions.
deceze
@deceze: I have edited my post, please check now.
Yogesh
+4  A: 

The best tool that I've used for the job is Fiddler. It lets you see the content of all the HTTP requests to and from your machine. One gotcha on Firefox though - make sure you restart once Fiddler is installed, and then go to the "Fiddler: Disabled" button in your status bar and select an option so that your Firefox traffic is watched as well.

derekerdmann
+4  A: 

You can use Live HTTP Headers (for Firefox).

Once you switch it ON, you can view all the HTTP headers that the browser sends (including form data etc.). VERY USEFUL for development purposes.

MovieYoda
Yes, it is useful for debugging, but I want a program that can produce a file like the one I stated in the question.
BlogueroConnor
+4  A: 

For more detailed information you could use WireShark. This program allows you monitor just about all traffic. It has a rather steep learning curve, when you get it, it is an awesome help.

Mostly I use Firebug. Setting the Console to 'persist' allows you to check GET/POST when submitting your form.

Michael
+4  A: 

The Firebug addon for Firefox can capture the data that you want. You will need to manually compile the data captured into the format that you want though.

D0cNet
A: 

If you're on Windows, Fiddler is a very good debugging proxy but you could also try out Charles Proxy which also has a lot of great features and is cross-platform.

Marc Novakowski
A: 

I'm quite fond of Burpsuite, it allows you to inspect and manipulate HTTP requests.

My favourite feature is the ability to intercept a request, modify parameters and then send it on. Very useful for security testing and debugging.

Neil Aitken
A: 

If you are using Forefox use Firebug, you can really good see what is happining. In Google Chrome and Safari you have BuildIn Developertools, so you can also see the same informations.

I found Fiddler a little bit difficult...

Fincha
I have Firebug but I don't know how to see this. Could you please care to explain where is the option to see the information I am looking for?
BlogueroConnor