httplib web client problem

Erik Myllymaki erik at pacific-shores.com
Mon Sep 25 13:15:38 EDT 2000


h.putheader("Content-length", "%d"%len(paramstring))

This line made all the difference.

Thanks all,

"Erik Myllymaki" <erik at pacific-shores.com> wrote in message
news:wEKz5.360354$8u4.3865644 at news1.rdc1.bc.home.com...
> Thanks for you help. I still seem to be having some problems though. My
> debug output now looks like this:
>
> send: 'POST /mailadmin?admin:mailboxes:makebox HTTP/1.0\015\012'
> send: 'Authorization: Basic
> cm9vdEBwYWNpZmljLXNob3Jlcy5jb206dGltZTM0\015\012'
> send: '\015\012'
> send: 'fullname=TestUser&userid=temp&password=letmein&mailhandling=return'
> reply: 'HTTP/1.1 200 OK\015\012'
>
> But the server still doesn't seem to recognize the variables.
>
> Maybe there is a cookie that I need to deal with?
>
> Thanks again,
>
> "Fredrik Lundh" <effbot at telia.com> wrote in message
> news:lLCz5.569$d5.31021 at newsb.telia.net...
> > Erik wrote:
> > > >The request gets sent through without an error, but the
> > > >server doesn't seem to recognize my request variables that I send in
> the
> > > >header?
> > > >
> > > >. . .
> > > >
> > > >This is the client that I am trying to use in place of the above
form:
> > > > . . .
> > > >h = httplib.HTTP(Server)
> > > >h.putheader('userid', 'user')
> > > >h.putheader('fullname', 'Full Username')
> > > >h.putheader('mailhandling', '~')
> > > >h.putheader('password', 'letmein')
> >
> > "putheader" is used for protocol-level things, like the
> > size and type of the body, etc.  it's not used to send
> > application-level data.
> >
> > Kragen:
> > > Form variables aren't sent as extra HTTP headers, which is how you are
> > > sending them; in POST, they're sent in the body.  It looks like you
> > > need to call the send() method to send the form variables (after you
> > > call endheaders()), but I'm not sure if there's an off-the-shelf way
to
> > > encode the parameters properly or if you need to do that yourself by
> > > hand.
> >
> > use urllib instead of httplib:
> >
> > data = {
> >     "userid": "user",
> >     "fullname": "Full Username",
> >     ...
> > }
> >
> > f = urllib.urlopen(url, urllib.urlencode(data))
> >
> > for details, see the urllib documentation.
> >
> > </F>
> >
> > <!-- (the eff-bot guide to) the standard python library:
> > http://www.pythonware.com/people/fredrik/librarybook.htm
> > -->
> >
>
>





More information about the Python-list mailing list