Package smisk :: Module core :: Class Request
[frames] | no frames]

Class Request

object --+
         |
        Request
Known Subclasses:

A HTTP request
Instance Methods
 
__init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
a new object with type S, a subtype of T
__new__(T, S, ...)
None
log_error(...)
Log something through errors including process name and id.

Inherited from object: __delattr__, __getattribute__, __hash__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties
dict cookies
Any cookies that was attached to the request.
dict env
HTTP transaction environment.
Stream errors
dict files
Any files uploaded via a POST request.
dict get
Parameters passed in the query string part of the URL.
Stream input
Input stream.
bool is_active
Indicates if the request is active, if we are in the middle of a HTTP transaction
dict post
Parameters passed in the body of a POST request.
object session
Current session.
string session_id
Current session id.
URL url
Reconstructed URL.

Inherited from object: __class__

Method Details

__init__(...)
(Constructor)

 
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Overrides: object.__init__

__new__(T, S, ...)

 
Returns: a new object with type S, a subtype of T
Overrides: object.__new__

log_error(...)

 

Log something through errors including process name and id.

Normally, errors ends up in the host server error log.

Parameters:
  • message (string) - Message
Returns: None
Raises:

Property Details

input

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 of how to parse a JSON request:

import cjson as json
import smisk
class App(smisk.Application):
  def service(self):
    if self.request.env['REQUEST_METHOD'] == 'POST':
      self.response.write(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

session

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