|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
Need the unparsed post dataI'm working with the cherrypy.request.rfile object. When I call read(), it blocks and then times out. How do I get the post body, when the client doesn't specify the content length? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "TurboGears" group. To post to this group, send email to turbogears@... To unsubscribe from this group, send email to turbogears+unsubscribe@... For more options, visit this group at http://groups.google.com/group/turbogears?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Need the unparsed post dataMatt Wilson schrieb: > I'm working with the cherrypy.request.rfile object. > > When I call read(), it blocks and then times out. How do I get the > post body, when the client doesn't specify the content length? A client which does not supply the content-length for a POST request is not HTTP 1.0 compliant. From the RFC [1]: "A valid Content-Length is required on all HTTP/1.0 POST requests. An HTTP/1.0 server should respond with a 400 (bad request) message if it cannot determine the length of the request message's content." For a somewhat related problem see this ticket: http://trac.turbogears.org/ticket/1953 Chris [1] http://tools.ietf.org/html/rfc1945#section-8.3 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "TurboGears" group. To post to this group, send email to turbogears@... To unsubscribe from this group, send email to turbogears+unsubscribe@... For more options, visit this group at http://groups.google.com/group/turbogears?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Need the unparsed post dataOn Sep 25, 3:17 pm, Christopher Arndt <chris.ar...@...> wrote: > A client which does not supply the content-length for a POST request is > not HTTP 1.0 compliant. From the RFC [1]: > > "A valid Content-Length is required on all HTTP/1.0 POST requests. An > HTTP/1.0 server should respond with a 400 (bad request) message if it > cannot determine the length of the request message's content." That's good to know. I'm working with a third-party vendor, and I don't trust that they'll always include that information. For future reference, here's how I extract the post data: import cherrypy @expose() def raw(self): if cherrypy.request.method == "POST": postdata = cherrypy.request.body.read() # it is also possible to do this: cl = int(cherrypy.request.headers['Content-Length']) postdata = cherrypy.request.body.read(cl) Thanks for the help! Matt --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "TurboGears" group. To post to this group, send email to turbogears@... To unsubscribe from this group, send email to turbogears+unsubscribe@... For more options, visit this group at http://groups.google.com/group/turbogears?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Need the unparsed post dataMatt Wilson schrieb: > On Sep 25, 3:17 pm, Christopher Arndt <chris.ar...@...> wrote: > >> A client which does not supply the content-length for a POST request is >> not HTTP 1.0 compliant. From the RFC [1]: >> >> "A valid Content-Length is required on all HTTP/1.0 POST requests. An >> HTTP/1.0 server should respond with a 400 (bad request) message if it >> cannot determine the length of the request message's content." > > That's good to know. I'm working with a third-party vendor, and I > don't trust that they'll always include that information. If they don't, immediatly botch the request. You *can't* possibly make sense out of it - based on what criteria would you consider the stream to be finished? If they chose to spoon-feed you one byte every fortnight, you wouldn't have a clue if it's fully transmitted or not. Diez --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "TurboGears" group. To post to this group, send email to turbogears@... To unsubscribe from this group, send email to turbogears+unsubscribe@... For more options, visit this group at http://groups.google.com/group/turbogears?hl=en -~----------~----~----~----~------~----~------~--~--- |
| Free Forum Powered by Nabble | Forum Help |