% in POST when using URLLIB2.URLOPEN with PROXY

H

Herman Geldenhuys

Hey.

Im trying to post some variables to an URL, but I get an error saying that
my XML is parsed incorrectly. I know that it is not. At closer inspection
I found out that some module in Python must be screwing up my request when
I try to send it.

Previously the code worked fine, but the problem occured when I included
the proxy/authentication code, so that must be what is messing around with
my request.

I substituted the original URL with a Zope script to post variable and
send them back to see what I get, testing it with and without the Proxy
code.

Here is the code:
#==========================

import urllib2

infoRequest = "<GETCLIENTSERVICES/>"
# VARIABLES TO SEND... it is the ArcXMLRequest that's going haywire!
params = urllib.urlencode({'ArcXMLRequest': infoRequest,
'JavaScriptFunction':'processXML',
'RedirectURL':'',
'BgColor':'#000000',
'FormCharset':'ISO-8859-1'})

proxy_info = {'port': 8080,
'host': '172.16.13.9',
'user': 'username',
'pass': 'password'}

proxy_support = urllib2.ProxyHandler({"http" :
"http://%(user)s:%(pass)s@%(host)s:%(port)s" %
proxy_info})

opener = urllib2.build_opener(proxy_support, urllib2.HTTPHandler)

urllib2.install_opener(opener)

req = urllib2.Request('http://serverX/debugScript', params) # Zope
server, or ARCIMS Server

u = urllib2.urlopen(req)
print u.read()

#===========================

http://serverX/debugScript only returns the ArcXMLRequest that was posted.
It should be :
"<GETCLIENTSERVICES/>"
but instead I get :
"<GETCLIENTSERVICES/%"

When I send "<GETCLIENTSERVICES/>\n\n" instead of "<GETCLIENTSERVICES/>",
I get back "<GETCLIENTSERVICES/>\n%" as a result.

If I'm not clear enough about the problem, please shout. Help will be
appreciated!!

Thanks

Herman
 
J

John J. Lee

Herman Geldenhuys said:
http://serverX/debugScript only returns the ArcXMLRequest that was posted.
It should be :
"<GETCLIENTSERVICES/>"
but instead I get :
"<GETCLIENTSERVICES/%"

When I send "<GETCLIENTSERVICES/>\n\n" instead of "<GETCLIENTSERVICES/>",
I get back "<GETCLIENTSERVICES/>\n%" as a result.

If I'm not clear enough about the problem, please shout. Help will be
appreciated!!
[...]

I wonder why, given your very clear explanation of the problem, you
haven't gone the extra inch to figure out why the code (urllib2+your
code) is posting incorrect data.

Somebody here might well guess the right answer to the problem, but
why not simply find out for yourself -- you're obviously quite capable
of doing so! Get those print statements in there!

Once you've done so, please help save the world and let us know what
the problem was.


John
 

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

Forum statistics

Threads
473,968
Messages
2,570,152
Members
46,697
Latest member
AugustNabo

Latest Threads

Top