[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

post headers

Daun Jaun

11/9/2004 6:13:00 PM

Hi all,

This is my first mail to this mailing list;

It will be nice if any one can tell me how to post cookies to a url;

I have done something like this

hdr['cookies']= "a_string_representation_of_all_the_cookies"

# I am not sure about the above step because I havenot found any example which
# posts headers along with cookies in Pragmatic..Ruby

h=Net::HTTP.new('www.isical.ac.in',80)
resp,data=h.post(path,query,hdr)

But i am getting error page from the server;
It says "parameter format error"

Is there any library routine for converting array of cookies to format
that post is expecting

Please Help..,
Thanx in advance
Daun Jaun


2 Answers

Ara.T.Howard

11/10/2004 4:18:00 PM

0

Daun Jaun

11/10/2004 5:16:00 PM

0

Hi Thanx for your reply Howard.
Actually i thought my mail did not reach the mailing list and
so mailed the same query to the group once more
Everybody please forgive me for that.

Hello Howard it goes like this

#file name : router.rb
#!/usr/bin/ruby -W0

require 'helpme' # have some miscellany functions

cgi=CGI.new('html3')

ckyArr=[ ]
for name,cky in cgi.cookies
ckyArr<<cky
ckyArr[-1].name=name
end

tmp=formatCookie(ckyArr)

# assume some formatting ..,
# hopefully i have done it right coz i have seen few raw pkts and
# coded this

hdr=Hash.new
hdr['Cookie']=tmp

site='www.isical.ac.in'
targ=cgi['path']

prms=""
cgi.params.each{|key,val|
if(key!='path')
prms<<key<<"="
val.each{|obj|
prms<<obj
# if this is an array i dont know what to do here
# but i can check it later
}
prms<<"&"
end
}
query="?"<<prms

h=Net::HTTP.start(site)

resp, data = h.post(targ,query,hdr)
# here is my problem What is this Hdr format in the above func

# The data i got from "isical" is given to the client

cgi.out(){
data
}