Help with a HTTP GET request

P

Paul Hemans

I am trying to build a HTTP request that looks like:
http://localhost/common/foxisapi.dll/tmsmail.x2.isapi?<PROCESS%20sync=''%20schema=''%20class='replicateApplication.getChanges'%20/>
Works in a browser.

lxml.parse() gives me:
failed to load external entity

urllib2.urlopen() gives me:
Bad request

So I am trying httplib I have encoded the GET request with urllib.quote
()
and now I am attempting to use HTTPConnection
%3CPROCESS%20sync%3D%27%27%20schema%3D%27%27%20class%3D
%27replicateApplication.getChanges%27%20/%3E
<html><head><title>Error</title></head><body>The parameter is
incorrect.
</body></html>

Any help would be appreciated.
 
T

Tim Harig

http://localhost/common/foxisapi.dll/tmsmail.x2.isapi?<PROCESS%20sync=''%20schema=''%20class='replicateApplication.getChanges'%20/>

Note the entire URL.
So I am trying httplib I have encoded the GET request with urllib.quote

urllib would be much easier if you don't need low level control -- it will
automatically call httplib for you.

For one, x does not contain the entire request.
"/common/foxisapi.dll/tmsmail.x2.isapi?" Should also be part of the
request; otherwise, the server doesn't know which script to call. Your
script is requesting the QUERY_STRING instead of requesting the proper
script and handing the QUERY_STRING to it. The report you are getting back
is likely your default top level script minus any rewrites or redirection.

If you just need the content of the request, then I suggest using urllib:

import urllib
url = "http://localhost/common/foxisapi.dll/tmsmail.x2.isapi?<PROCESS%20sync=''%20schema=''%20class='replicateApplication.getChanges'%20/"
content = urllib.urlopen(url).read()
 
T

Tim Harig

host = "http://localhost"
request = r"""/common/foxisapi.dll/tmsmail.x2.isapi?<PROCESS sync='' schema='' class='replicateApplication.getChanges' /"""
url = host + urllib.quote(request)
content = urllib.urlopen(url).read()

Which accidentally encodes the '?' separator. Third times a charm:
host = "http://localhost"
script = "/common/foxisapi.dll/tmsmail.x2.isapi"
getData = r"""<PROCESS sync='' schema='' class='replicateApplication.getChanges' /"""
url = host + script + '?' + urllib.quote(getData)
content = urllib.urlopen(url).read()
 
C

Carbon-based

Great, thank you very much.

Which accidentally encodes the '?' separator.  Third times a charm:
host = "http://localhost"
script = "/common/foxisapi.dll/tmsmail.x2.isapi"
getData = r"""<PROCESS sync='' schema='' class='replicateApplication.getChanges' /"""
url = host + script + '?' + urllib.quote(getData)
content = urllib.urlopen(url).read()
 

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

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top