Http header

Hi,

i want to sent an accept in a http header, but it doesn’t work. I use this
code (and also tried many others):
h = Net::HTTP.new(“www.anyserver.de”, 80)
resp, body = h.get("/index.html", “accept” => “/” )

Any suggestions?

Thanks a lot

h = Net::HTTP.new("www.anyserver.de", 80)
  resp, body = h.get("/index.html", "accept" => "*/*" )

Well, it work for me try this

   h = Net::HTTP.new("www.anyserver.de", 80)
   h.set_debug_output($stderr)
   resp, body = h.get("/index.html", "accept" => "*/*" )

and you'll see what it send

Guy Decoux

Hi,
okay but now I can only see what ruby does. I have a sniffer running to
control if its sending the accept command. But there is nothing else shown
than GET /index.html. Don’t know any further.

“ts” decoux@moulon.inra.fr schrieb im Newsbeitrag
news:200212231211.gBNCBsk05893@moulon.inra.fr

···

h = Net::HTTP.new(“www.anyserver.de”, 80)
resp, body = h.get(“/index.html”, “accept” => “/” )

Well, it work for me try this

h = Net::HTTP.new(“www.anyserver.de”, 80)
h.set_debug_output($stderr)
resp, body = h.get(“/index.html”, “accept” => “/” )

and you’ll see what it send

Guy Decoux

okay but now I can only see what ruby does. I have a sniffer running to
control if its sending the accept command. But there is nothing else shown
than GET /index.html. Don't know any further.

Your sniffer is broken, change it :slight_smile:

pigeon% cat b.rb
#!/usr/bin/ruby
require 'net/http'
h = Net::HTTP.new("www.ruby-lang.org", 80)
h.set_debug_output($stderr)
resp, body = h.get("/en/index.html", "accept" => "*/*")
pigeon%

pigeon% b.rb
opening connection to www.ruby-lang.org...
opened
<- "GET /en/index.html HTTP/1.1\r\n"
<- "Connection: close\r\n"
<- "Accept: */*\r\n"
<- "Host: www.ruby-lang.org\r\n"
<- "\r\n"
-> "HTTP/1.1 200 OK\r\n"
-> "Date: Mon, 23 Dec 2002 14:01:34 GMT\r\n"
-> "Server: Apache/1.3.26 (Unix) Debian GNU/Linux mod_ruby/0.9.7 Ruby/1.6.7\r\n"
-> "Last-Modified: Mon, 16 Dec 2002 07:45:02 GMT\r\n"
-> "ETag: \"1dcbe-1d52-3dfd847e\"\r\n"
-> "Accept-Ranges: bytes\r\n"
-> "Content-Length: 7506\r\n"
-> "Connection: close\r\n"
-> "Content-Type: text/html\r\n"
-> "\r\n"
reading 7506 bytes...
read 7506 bytes
Conn close
closed
pigeon%

pigeon# sniffit -t www.ruby-lang.org
Supported Network device found. (eth0)
Sniffit.0.3.7 Beta is up and running.... (www.ruby-lang.org)

Gracefull shutdown...
pigeon#

pigeon# cat 138.102.114.46.58388-210.251.121.214.80
GET /en/index.html HTTP/1.1
Connection: close
Accept: */*
Host: www.ruby-lang.org

pigeon#

Guy Decoux