Thanks for trying to help Niphlod. More details so far. Strangely, that problem does NOT exist when I test with http://web2py.com/examples/simple_examples/status
So I compare the output page between mine and the one from web2py.com, then I found something. On my server's output, there are only TWO appearances of "application/json", one in request.env.content_type and another in request.wsgi.environ.CONTENT_TYPE. On web2py.com's output, there are FOUR appearances of "application/json", they are request.env.content_type, request.env.http_content_type, request.wsgi.environ.CONTENT_TYPE, and request.wsgi.environ.HTTP_CONTENT_TYPE. And turns out line 343 of parse_get_post_vars() uses only "http_content_type" to trigger the json support. http://code.google.com/p/web2py/source/browse/gluon/main.py No wonder the symptom. So the next question is, what makes the request.env.http_content_type missing in my case? Is it somehow because my apache sits behind an nginx (a webfaction convention) so the request.is_local is always True (which is not the case of web2py.com)? Or, shall we simply change that line 343 of gluon/main.py into this: is_json = (env.get('http_content_type', '') or env.get('content_type', '') )[:16] == 'application/json' Thoughts? On Thursday, August 1, 2013 5:49:24 PM UTC+8, Niphlod wrote: > > I really can't reproduce it. Can you log somewhere within the > parse_get_post_vars function what happens ? > > On Thursday, August 1, 2013 8:53:09 AM UTC+2, Ray (a.k.a. Iceberg) wrote: >> >> To whom it may concern: >> >> I tried posting vars in json format, with content-type: application/json >> header, to my web2py application. >> >> When the above test is run on my laptop, i.e. requests are sent directly >> to web2py's rocket web server, recent web2py (the 2.5.1-stable) can >> successfully decode the payload into request.vars, as expected as mentioned >> in https://groups.google.com/d/msg/web2py/9YdxVpuJlA8/ek0zJae5U9YJ >> >> But when I deploy my application to my production server, the same web2py >> 2.5.1-stable can not recognize the payload and the request.vars are always >> empty. How come? >> >> My production server is running a web2py (was 2.4.6, and then manually >> overwritten by those files in 2.5.1's web2py_src.zip), behind apache's >> mod_wsgi, (which itself is behind a global nginx, but that architecture is >> a webfaction convention which I think is not relevent). >> >> Below is the request full content: >> >> *POST /examples/simple_examples/status/foo/bar.json HTTP/1.1*content-type: >> application/jsonHost: example.comContent-Length:14user-agent: fake >> Connection:Keep-Alive >> >> >> {"foo": "bar"} >> >> >> And below is part of the web2py response, showing the request content. You >> can see web2py got the correct content type header, but still fail to decode >> the json payload in request. >> >> env: >> >> >> >> >> >> >> content_length: >> 14 >> content_type: >> application/json >> http_connection: >> close >> http_forwarded_request_uri: >> /examples/simple_examples/status/foo/bar.json >> http_host: >> sandbox.xxxxxxxx.com >> http_http_x_forwarded_proto: >> http >> http_https: >> off >> http_user_agent: >> fake >> http_x_forwarded_for: >> 107.23.xxx.xxx >> http_x_forwarded_host: >> sandbox.xxxxxxxx.com >> http_x_forwarded_proto: >> http >> http_x_forwarded_server: >> sandbox.xxxxxxxx.com >> http_x_forwarded_ssl: >> off >> >> >> post_vars: >> >> vars: >> >> wsgi: >> environ: >> CONTENT_LENGTH: >> 14 >> CONTENT_TYPE: >> application/json >> >> >> >> >> >> -- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.