To explain my problem better, please see following (incomplete pseudo) code:

import webob

class Decider:
   def handle(self, env):
       request = webob.Request(env.copy())
       if request.charset is None:
           request.charset = 'utf8'
       # do something more useful here
       port = random.randint(request.POST['start'], request.POST['end'])


def application(env, start_response):
   router = Decider()
   port = router.handle(env)
   # we have various uwsgi servers awaiting http requests at ports 30XX (start 
< XX < end)
   fd = ':30' + str(port)
   # webob.Request creation will read body, is there a way to rewind?
   env['wsgi.input'].read(-1)
   for part in uwsgi.send_message(fd, 0, 0, env, 0, env['wsgi.input'].fileno(), 
uwsgi.cl()):
       yield part

Setup is a uwsgi emporer setup, 1 router (code above), and a certain number of 
uwsgi servers with http-sockes awaiting requests.

Can I use uwsgi to solve this problem?

Thanks,
Kaweh


On 29.06.2012, at 16:00, Kaweh Kazemi wrote:

> Hi there,
> 
> based on the examples here:
> 
>       http://projects.unbit.it/uwsgi/wiki/CustomRouting
> 
> I try to figure out, how to read the HTTP body and forward it at the same 
> time with uwsgi.send_message.
> 
> My custom routing needs to read the HTTP body to make a routing decision. 
> Doing e['uwsgi.input'].read does not work, because there is no seek(-1) 
> possible (uwsgi._Input). I also tried to fdopen(e['uwsgi.input'].fileno()) to 
> no avail.
> 
> Is there a way to do that?
> 
> Thanks,
> Kaweh
> _______________________________________________
> uWSGI mailing list
> [email protected]
> http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi


_______________________________________________
uWSGI mailing list
[email protected]
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi

Reply via email to