httplib web client problem

Erik Myllymaki erik at pacific-shores.com
Sun Sep 24 21:59:52 EDT 2000


I am having some problems trying to access a web-based email administration
page from python.  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?

The following is the form that is used from the admin page to create a new
mailbox:
----------------------------------------------------------------------------
----------------------------
<form method=POST
action="http://somemailserver.com/mailadmin?admin:mailboxes:makemailbox">
   <table border=0 align=center width=80%>
   <tr><td width=25%><B>Mailbox ID:</B></td><td><input type=text name=userid
value='' size=10></td></tr>
   <tr><td width=25%><B>Full name:</B></td><td><input type=text
name=fullname value='' size=40></td></tr>
   <tr><td width=25% valign=top><B>Mail Handling:</B></td>
   <td valign=top><select name=mailhandling>
                  <option select value="~">Store for pickup
                  <option value="<>">Return to sender
                  <option value="forward">Forward email
                 </select></td></tr>
   <tr><td width=25%><B>Password:</B></td><td><input type=text name=password
value='' size=12></td></tr>
   </table>
   <BR clear=all>
   <center>
   <input type=submit value="Create Mailbox">
   </form>


This is the client that I am trying to use in place of the above form:
---------------------------------------------------------------

import httplib, string, base64, pprint, mimetools

user = "myusername"
passwd = "letmein"
Server = "www.somemailserver.com"
Page = "/mailadmin?admin:mailboxes:addmailbox"
auth = 'Basic ' + string.strip(base64.encodestring(user + ":" + passwd))

h = httplib.HTTP(Server)
h.set_debuglevel(1)
h.putrequest('POST', Page)
h.putheader('Authorization', auth)
h.putheader('userid', 'user')
h.putheader('fullname', 'Full Username')
h.putheader('mailhandling', '~')
h.putheader('password', 'letmein')
h.endheaders()
errorcode, responsemessage, headers = h.getreply()
f=h.getfile()
data = f.read()
f.close()
print data
print errorcode
print responsemessage
print headers



This is the debug info that I receive from python:
----------------------------------------------------------
send: 'POST /mailadmin?admin:mailboxes:addmailbox HTTP/1.0\015\012'
send: 'userid: user\015\012'
send: 'Authorization: Basic
dHR0dHRAcGFjaWZpYy1zaG9yZXMuY29tOmxldG1laW4=\015\012'
send: 'fullname: Full Username\015\012'
send: 'mailhandling: ~\015\012'
send: 'password: letmein\015\012'
send: '\015\012'
reply: 'HTTP/1.1 200 OK\015\012'


Any advice apreciated.


Erik Myllymaki
erik at pacific-shores.com





More information about the Python-list mailing list