tags:

views:

373

answers:

2

I'm reading some documentation on a service I'm trying to use, and it reads something like this:

All requests must be sent using HTTP Post.

The XML engine only accepts plain ASCII (text) UTF-8 requests/streams. Encoded streams are not acceptable.

All requests/responses are XML.

But I really just don't understand what it's asking for. From what I've been reading on HTTP POST in Python, you still need to encode key=value pairs to make a request, where it sounds like they just want the plain XML itself (as a multipart, maybe? I am very confused). Are they giving me enough information and I'm just fundamentally misunderstanding their documentation, or should I ask for more details?

+1  A: 

"plain ASCII UTF-8" is a contradiction in terms, IMHO -- ASCII is a subset of UTF-8, though. Try sending UTF-8 including some "special" (non-ASCII) character and see what happens (or, if you can, do ask them to reword said contradition-in-terms!-).

Alex Martelli
I think they're just missing an "or". I don't think you understand my confusion - I don't know how to send either an ASCII or UTF-8 request, only how to send key=value requests... just confused in general.
@Roger: Even "or" doesn't fit: One could just say "UTF-8" and that would mean ASCII is allowed as well since UTF-8 includes ASCII.
nosklo
+2  A: 

using urllib2.Request

import urllib2
req = urllib2.Request("http://foo.com/post_here", "<xml data to post>")
response = urllib2.urlopen(req)
the_page = response.read()
cobbal