Skip to content

Instantly share code, notes, and snippets.

@andreyuhai
Last active November 27, 2020 06:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andreyuhai/bb1fa46b871f62e8e0c389be906ae5af to your computer and use it in GitHub Desktop.
Save andreyuhai/bb1fa46b871f62e8e0c389be906ae5af to your computer and use it in GitHub Desktop.
If you ever need to debug mechanize request headers

Ruby Mechanize Debug Request Headers

If you are trying to debug your headers:

Start listening on some port:

nc -kl 1234

Then just send a request to that port:

require 'mechanize'

agent = Mechanize.new
agent.get('http://localhost:1234')

Afterwards you will see all the headers sent to on the terminal screen where you'd ran nc command.

GET / HTTP/1.1
Accept-Encoding: gzip,deflate,identity
Accept: */*
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:43.0) Gecko/20100101 Firefox/43.0
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Accept-Language: en-us,en;q=0.5
Host: localhost:1234
Connection: keep-alive
Keep-Alive: 300
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment