A best approach to a creating specified http post body

D

dzawer

Hi all, I'm rather new to python but not exaclty without programming
experience and not quite get best pyhton practices.
I have a following problem that it seems I cannot find a way to solve
correctly.

I need to build a special http post body that consists of :
name=value +\r\n strings.
Problem is that depending on operations the number of name,value
pairs can increase and decrease.
Values need to be initialized at runtime, so storing premade text
files is not possible.

The worst thing that some operations must be at beginning, so
dictionary approach with classes is kinda out.

Could you please provide some examples or descriptions on how you
would solve such problem ?
Thanks in advance.
 
D

Dave Borne

I need to build a special http post body that consists of :
name=value +\r\n strings.
Problem is that depending on operations the number of name,value
pairs can increase and decrease.
Values need to be initialized at runtime, so storing premade text
files is not possible.

I'm not completely understanding your problems here. Can you explain
why urllib.urlencode wouldn't work?
(http://docs.python.org/lib/module-urllib.html)

Thanks,
-Dave
 
F

Facundo Batista

Hmm, I guess I meant something different by using "body"- I meant
request data part and not the thing sent in ulr string.

You should specify better what you need yes.

See, to send POST information in an http request, you can do the
following...

....being postbody a string with the information you want to send, for
example "Hello world", "a=5&no=yes", or "\n\n\r\tMMalichorhoh829dh9ho2"

So, you need help building a post body, or you need building a string?

Regards,
 

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,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top