post headers

D

Daun Jaun

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
 
A

Ara.T.Howard

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

perhaps

harp:~ > irb -r cgi
irb(main):001:0> c=CGI::Cookie.new("rubyweb", "CustID=123", "Part=ABC")
=> ["CustID=123", "Part=ABC"]

irb(main):002:0> c.to_s
=> "rubyweb=CustID%3D123&Part%3DABC; path="


without you posting the complete code it's hard to say more than this. are you
able to post the code, distilled to show the problem?

cheers.


-a
--
===============================================================================
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| When you do something, you should burn yourself completely, like a good
| bonfire, leaving no trace of yourself. --Shunryu Suzuki
===============================================================================
 
D

Daun Jaun

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
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top