Input stream.
If you send any data which is neither x-www-form-urlencoded nor multipart format, you will be able to read the raw POST body from this stream.
You could read x-www-form-urlencoded or multipart POST requests in raw format, but you have to read from this stream before calling any of post or files, since they will otherwise trigger the built-in parser and read all data from the stream.
Example, parsing a JSON request:
from smisk.core import *
from smisk.serialization.json import json_decode
class App(Application):
def service(self):
if request.env['REQUEST_METHOD'] == 'POST':
response('Input: ', repr(json_decode(self.request.input.read())), "\n")
App().run()
You could then send a request using curl for example:
curl --data-binary '{"Url": "http://www.example.com/image/481989943", "Position": [125, "100"]}' http://localhost:8080/
| Type: | Stream |
|---|
HTTP transaction environment.
| Type: | dict |
|---|
Reconstructed URL
For example; if you need to know if running under SSL:
if request.url.scheme == 'https':
response('Secure connection')
else:
response('Big brother is watching you')
| Type: | URL |
|---|
Parameters passed in the query string part of the URL
| Type: | dict |
|---|
Parameters passed in the body of a POST request
| Type: | dict |
|---|
Any files uploaded via a POST request
| Type: | dict |
|---|
Any cookies that was attached to the request
| Type: | dict |
|---|
Current session.
Any modifications to the session must be done before output has begun, as it will add a Set-Cookie: header to the response.
| Type: | object |
|---|
Current session id
| Type: | string |
|---|
Indicates if the request is active, if we are in the middle of a HTTP transaction
| Type: | bool |
|---|