[lnkForumImage]
TotalShareware - Download Free Software

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


 

Daun Jaun

11/10/2004 1:49:00 PM

Hi
Can some one please tell me how to encode the headers(HTTP request) in the call
to HTTP post method

the signature of post was

def Net::Http.post( path, query, header )

But no where in the manual can i found something about this header
except that its a HASH

Awaiting eagerly for your replies
Bye
Daun Jaun


10 Answers

Doug Kearns

11/10/2004 10:01:00 PM

0

On Wed, Nov 10, 2004 at 10:49:20PM +0900, Daun Jaun wrote:
> Hi
> Can some one please tell me how to encode the headers(HTTP request) in the call
> to HTTP post method
>
> the signature of post was
>
> def Net::Http.post( path, query, header )
>
> But no where in the manual can i found something about this header
> except that its a HASH

To find out more about HTTP headers:
http://www.w3.org/Protocols/rfc2616/rfc2616-...

require 'net/http'
Net::HTTP.start('localhost', 80) { |http|
response = http.post('/index.html', {'Host' => 'localhost', 'User-Agent' => 'MyBrowser'});
}

Regards,
Doug


Mark Hubbart

11/10/2004 10:10:00 PM

0

Hi,

On Wed, 10 Nov 2004 22:49:20 +0900, Daun Jaun <compsci.isi@gmail.com> wrote:
> Hi
> Can some one please tell me how to encode the headers(HTTP request) in the call
> to HTTP post method
>
> the signature of post was
>
> def Net::Http.post( path, query, header )
>
> But no where in the manual can i found something about this header
> except that its a HASH

It's optional. If you want to include additional http headers, like
the referer, or the size of the data you are posting, call it like
this:

result = server.post("/", data, {"Referer" => "http://example...,
"Content-Length" => data.size})

If you don't know if you need to send extra headers, then you probably
don't need to :) So just omit them:

result = server.post("/",data)

HTH,
Mark

>
> Awaiting eagerly for your replies
> Bye
> Daun Jaun
>
>


Daun Jaun

11/11/2004 4:53:00 AM

0

What if i want to send cookies;
should i place it in headers if so how should i format the cookies ..,
its where my problem exactly is
COOKIES..?




On Thu, 11 Nov 2004 07:10:26 +0900, Mark Hubbart <discordantus@gmail.com> wrote:
> Hi,
>
>
>
> On Wed, 10 Nov 2004 22:49:20 +0900, Daun Jaun <compsci.isi@gmail.com> wrote:
> > Hi
> > Can some one please tell me how to encode the headers(HTTP request) in the call
> > to HTTP post method
> >
> > the signature of post was
> >
> > def Net::Http.post( path, query, header )
> >
> > But no where in the manual can i found something about this header
> > except that its a HASH
>
> It's optional. If you want to include additional http headers, like
> the referer, or the size of the data you are posting, call it like
> this:
>
> result = server.post("/", data, {"Referer" => "http://example...,
> "Content-Length" => data.size})
>
> If you don't know if you need to send extra headers, then you probably
> don't need to :) So just omit them:
>
> result = server.post("/",data)
>
> HTH,
> Mark
>
>
>
> >
> > Awaiting eagerly for your replies
> > Bye
> > Daun Jaun
> >
> >
>
>


Mark Hubbart

11/11/2004 7:35:00 AM

0

On Thu, 11 Nov 2004 13:52:51 +0900, Daun Jaun <compsci.isi@gmail.com> wrote:
> What if i want to send cookies;
> should i place it in headers if so how should i format the cookies ..,
> its where my problem exactly is
> COOKIES..?

Google is your friend :) Googling 'cookie header' gives us:
http://wp.netscape.com/newsref/std/cookie...

the format for the header is:

Set-Cookie: NAME=VALUE; expires=DATE;
path=PATH; domain=DOMAIN_NAME; secure

So the header hash might look something like this:

cookie = "NAME=foo;expires=Wdy, DD-Mon-YYYY HH:MM:SS GMT;"+
"domain=example.com;path=/foo/bar;"
{"Set-Cookie" => cookie}

cheers,
Mark


Daun Jaun

11/11/2004 7:58:00 AM

0

Thanx for ur response;

seems i am not clearly explaining u what i want;

I am not interested in sending cookies to the browser/client; infact

I am playing the role of a browser here and i want to talk to the server

and in this situation i have to send (stored) cookies (at browser say)

to the program@server

This format or way of doing this is different from the way we play a
server role and send cookies to the client ; its can be
easily done using cgi.out
Unfortunately the same way does not work out with
httpObj.post

And coming to http_access2 its all complex i am unable to understand

Please help me..........



On Thu, 11 Nov 2004 16:34:40 +0900, Mark Hubbart <discordantus@gmail.com> wrote:
> On Thu, 11 Nov 2004 13:52:51 +0900, Daun Jaun <compsci.isi@gmail.com> wrote:
> > What if i want to send cookies;
> > should i place it in headers if so how should i format the cookies ..,
> > its where my problem exactly is
> > COOKIES..?
>
> Google is your friend :) Googling 'cookie header' gives us:
> http://wp.netscape.com/newsref/std/cookie...
>
> the format for the header is:
>
> Set-Cookie: NAME=VALUE; expires=DATE;
> path=PATH; domain=DOMAIN_NAME; secure
>
> So the header hash might look something like this:
>
> cookie = "NAME=foo;expires=Wdy, DD-Mon-YYYY HH:MM:SS GMT;"+
> "domain=example.com;path=/foo/bar;"
> {"Set-Cookie" => cookie}
>
> cheers,
> Mark
>
>


Edwin Eyan Moragas

11/11/2004 8:07:00 AM

0

> And coming to http_access2 its all complex i am unable to understand
>
> Please help me..........

breastfeeding is only best for babies.
--
i'm not flying. i'm falling... in style.


Daun Jaun

11/11/2004 8:58:00 AM

0

Thanx
No Thanx
I have spent more than 6 nites on this ..,
Its after that i have joined this list
If u cant help then y dont u just ignore

cheers
Daun Jaun


On Thu, 11 Nov 2004 17:06:48 +0900, Edwin Eyan Moragas <haaktu@gmail.com> wrote:
> > And coming to http_access2 its all complex i am unable to understand
> >
> > Please help me..........
>
> breastfeeding is only best for babies.
> --
> i'm not flying. i'm falling... in style.
>
>


Edwin Eyan Moragas

11/11/2004 9:27:00 AM

0

i was hoping you'd look at http_access2. if you have downloaded
the tar ball and at least looked at the sample dir, you'd get an idea on
how to use cookies. from there, you'd look at webagent or soap4r
and how these beasts manage cookies.

personally, i don;t have time to look at these but you would, since
you have the need.

you need to focus, and not just whine. i'm not trying to dis you.
just hoping that you;d do your part since i spent the time looking
for that darn piece of software you need.


On Thu, 11 Nov 2004 17:58:08 +0900, Daun Jaun <compsci.isi@gmail.com> wrote:
> Thanx
> No Thanx
> I have spent more than 6 nites on this ..,
> Its after that i have joined this list
> If u cant help then y dont u just ignore
>
> cheers
> Daun Jaun
>
>
>
>
> On Thu, 11 Nov 2004 17:06:48 +0900, Edwin Eyan Moragas <haaktu@gmail.com> wrote:
> > > And coming to http_access2 its all complex i am unable to understand
> > >
> > > Please help me..........
> >
> > breastfeeding is only best for babies.
> > --
> > i'm not flying. i'm falling... in style.
> >
> >
>
>


--
i'm not flying. i'm falling... in style.


Mark Hubbart

11/11/2004 9:59:00 AM

0

On Thu, 11 Nov 2004 16:57:41 +0900, Daun Jaun <compsci.isi@gmail.com> wrote:
> Thanx for ur response;
>
> seems i am not clearly explaining u what i want;
>
> I am not interested in sending cookies to the browser/client; infact
>
> I am playing the role of a browser here and i want to talk to the server
>
> and in this situation i have to send (stored) cookies (at browser say)
>
> to the program@server
>
> This format or way of doing this is different from the way we play a
> server role and send cookies to the client ; its can be
> easily done using cgi.out
> Unfortunately the same way does not work out with
> httpObj.post
>
> And coming to http_access2 its all complex i am unable to understand
>
> Please help me..........

indeed, I can see now that I answered the wrong question... Still, I'm
wondering if you visited the page I referenced, since it has your
solution on it. To quote:

---
When requesting a URL from an HTTP server, the browser will match the
URL against all cookies and if any of them match, a line containing
the name/value pairs of all matching cookies will be included in the
HTTP request. Here is the format of that line:

Cookie: NAME1=OPAQUE_STRING1; NAME2=OPAQUE_STRING2 ...
---

That should get you going on it...

cheers,
Mark


Daun Jaun

11/11/2004 1:45:00 PM

0

Yeah Edwin
I have peeped in to that code and samples early in the morning
But I am unable to grasp what is exactly goin on ;

I have to figure it out ;-)

But I dont want to take help of this http_access2 because I am not
developin a s/w which is as complex as a browser, all my piece of
s/w shud do is be a proxy ( intermediary*&# ) at an application layer
between the browser and the original server

_ _ _ _ _ _ _
| Browser | ----------> My Program at local host(say)
- - - - - - - - - |
|
V
-------------------------------
| server to which |
| I have to forwar the |
| request |
__________________



Aneway I am currently lookin at the rfc for cookies and also peeing
into http_access i will come back after some time
Now goin to try Marks way ....,

Bye
Daun Jaun










On Thu, 11 Nov 2004 18:58:36 +0900, Mark Hubbart <discordantus@gmail.com> wrote:
> On Thu, 11 Nov 2004 16:57:41 +0900, Daun Jaun <compsci.isi@gmail.com> wrote:
>
>
> > Thanx for ur response;
> >
> > seems i am not clearly explaining u what i want;
> >
> > I am not interested in sending cookies to the browser/client; infact
> >
> > I am playing the role of a browser here and i want to talk to the server
> >
> > and in this situation i have to send (stored) cookies (at browser say)
> >
> > to the program@server
> >
> > This format or way of doing this is different from the way we play a
> > server role and send cookies to the client ; its can be
> > easily done using cgi.out
> > Unfortunately the same way does not work out with
> > httpObj.post
> >
> > And coming to http_access2 its all complex i am unable to understand
> >
> > Please help me..........
>
> indeed, I can see now that I answered the wrong question... Still, I'm
> wondering if you visited the page I referenced, since it has your
> solution on it. To quote:
>
> ---
> When requesting a URL from an HTTP server, the browser will match the
> URL against all cookies and if any of them match, a line containing
> the name/value pairs of all matching cookies will be included in the
> HTTP request. Here is the format of that line:
>
> Cookie: NAME1=OPAQUE_STRING1; NAME2=OPAQUE_STRING2 ...
> ---
>
> That should get you going on it...
>
> cheers,
> Mark
>
>