httplib web client problem

Kragen Sitaker kragen at
Mon Sep 25 08:03:43 CEST 2000

In article <skyz5.356917$8u4.3831646 at>,
Erik Myllymaki <erik at> 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
>. . . 
>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')
> . . . 
>This is the debug info that I receive from python:
> . . .
>send: 'fullname: Full Username\015\012'
>send: 'mailhandling: ~\015\012'
>send: 'password: letmein\015\012'
>send: '\015\012'

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.  You want to send a string that looks something like

In Perl, I'd say $ua->request(POST $url, [userid => 'user', fullname =>
'Full Username']), etc.  Surely equivalent functionality exists for Python?
<kragen at>       Kragen Sitaker     <>
Perilous to all of us are the devices of an art deeper than we ourselves
                -- Gandalf the Grey [J.R.R. Tolkien, "Lord of the Rings"]

More information about the Python-list mailing list