Package twisted :: Package protocols :: Module http |
[frames | no frames]

## Module twisted.protocols.http

HyperText Transfer Protocol implementation.

This is used by twisted.web.

API Stability: Server HTTP support is semi-stable, client HTTP is unstable.

Future Plans:

- HTTP client support will at some point be refactored to support HTTP/1.1.
- Accept chunked data from clients in server.
- Other missing HTTP features from the RFC.

Maintainer: Itamar Shtull-Trauring

Classes
`HTTPChannel` | A receiver for HTTP requests.
`HTTPClient` | A client for HTTP 1.0
`HTTPFactory` | Factory for HTTP server.
`Request` | A HTTP request.
`StringTransport` | I am a StringIO wrapper that conforms for the transport API.

Function Summary
| `_logDateTimeStart()`
| `_logDateTimeStop()`
| `_resetLogDateTime()`
| ``datetimeToLogString`(msSinceEpoch)` Convert seconds since epoch to log datetime string.
| ``datetimeToString`(msSinceEpoch)` Convert seconds since epoch to HTTP datetime string.
| ``fromChunk`(data)` Convert chunk to string.
| ``parse_qs`(qs, keep_blank_values, strict_parsing, unquote)` like cgi.parse_qs, only with custom unquote function
| ``parseContentRange`(header)` Parse a content-range header into (start, end, realLength).
| ``stringToDatetime`(dateString)` Convert an HTTP date string to seconds since epoch.
| ``timegm`(year, month, day, hour, minute, second)` Convert time tuple in GMT to seconds since epoch, GMT
| ``toChunk`(data)` Convert string to a chunk.

Variable Summary
`int` | `_CONTINUE` = 100
`NoneType` | `_logDateTime` = None
`int` | `_logDateTimeUsers` = 0
`NoneType` | `_resetLogDateTimeID` = None
`int` | `ACCEPTED` = 202
`int` | `BAD_GATEWAY` = 502
`int` | `BAD_REQUEST` = 400
`str` | `CACHED` = `'Magic constant returned by http.Request method...`
`int` | `CONFLICT` = 409
`int` | `CREATED` = 201
`int` | `EXPECTATION_FAILED` = 417
`int` | `FORBIDDEN` = 403
`int` | `FOUND` = 302
`int` | `GATEWAY_TIMEOUT` = 504
`int` | `GONE` = 410
`int` | `HTTP_VERSION_NOT_SUPPORTED` = 505
`int` | `INSUFFICIENT_STORAGE_SPACE` = 507
`int` | `INTERNAL_SERVER_ERROR` = 500
`int` | `LENGTH_REQUIRED` = 411
`list` | `monthname` = `[None, 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'J...`
`int` | `MOVED_PERMANENTLY` = 301
`int` | `MULTI_STATUS` = 207
`int` | `MULTIPLE_CHOICE` = 300
`tuple` | `NO_BODY_CODES` = `(204, 304)`
`int` | `NO_CONTENT` = 204
`int` | `NON_AUTHORITATIVE_INFORMATION` = 203
`int` | `NOT_ACCEPTABLE` = 406
`int` | `NOT_ALLOWED` = 405
`int` | `NOT_EXTENDED` = 510
`int` | `NOT_FOUND` = 404
`int` | `NOT_IMPLEMENTED` = 501
`int` | `NOT_MODIFIED` = 304
`int` | `OK` = 200
`int` | `PARTIAL_CONTENT` = 206
`int` | `PAYMENT_REQUIRED` = 402
`int` | `PRECONDITION_FAILED` = 412
`str` | `protocol_version` = `'HTTP/1.1'`
`int` | `PROXY_AUTH_REQUIRED` = 407
`int` | `REQUEST_ENTITY_TOO_LARGE` = 413
`int` | `REQUEST_TIMEOUT` = 408
`int` | `REQUEST_URI_TOO_LONG` = 414
`int` | `REQUESTED_RANGE_NOT_SATISFIABLE` = 416
`int` | `RESET_CONTENT` = 205
`dict` | `responses` = `{400: 'Bad Request', 401: 'Unauthorized', 40...`
`dict` | `RESPONSES` = `{400: 'Bad Request', 401: 'Unauthorized', 40...`
`int` | `SEE_OTHER` = 303
`int` | `SERVICE_UNAVAILABLE` = 503
`int` | `SWITCHING` = 101
`int` | `TEMPORARY_REDIRECT` = 307
`int` | `UNAUTHORIZED` = 401
`int` | `UNSUPPORTED_MEDIA_TYPE` = 415
`int` | `USE_PROXY` = 305
`list` | `weekdayname` = `['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat',...`

Function Details

### datetimeToLogString(msSinceEpoch=None) Convert seconds since epoch to log datetime string.

### datetimeToString(msSinceEpoch=None) Convert seconds since epoch to HTTP datetime string.

### fromChunk(data) Convert chunk to string. Returns tuple (result, remaining), may raise ValueError.

### parse_qs(qs, keep_blank_values=0, strict_parsing=0, unquote=<Fake twisted.protocols._c_urlarg.unquote>) like cgi.parse_qs, only with custom unquote function

### parseContentRange(header) Parse a content-range header into (start, end, realLength). realLength might be None if real length is not known ('*').

### stringToDatetime(dateString) Convert an HTTP date string to seconds since epoch.

### timegm(year, month, day, hour, minute, second) Convert time tuple in GMT to seconds since epoch, GMT

### toChunk(data) Convert string to a chunk.

Variable Details

    ### _CONTINUE Type: `int` Value:
        100

    ### _logDateTime Type: `NoneType` Value:
        None

    ### _logDateTimeUsers Type: `int` Value:
        0

    ### _resetLogDateTimeID Type: `NoneType` Value:
        None

    ### ACCEPTED Type: `int` Value:
        202

    ### BAD_GATEWAY Type: `int` Value:
        502

    ### BAD_REQUEST Type: `int` Value:
        400

    ### CACHED Type: `str` Value:
        '''Magic constant returned by http.Request methods to set cache
        validation headers when the request is conditional and the value fails
        the condition.'''

    ### CONFLICT Type: `int` Value:
        409

    ### CREATED Type: `int` Value:
        201

    ### EXPECTATION_FAILED Type: `int` Value:
        417

    ### FORBIDDEN Type: `int` Value:
        403

    ### FOUND Type: `int` Value:
        302

    ### GATEWAY_TIMEOUT Type: `int` Value:
        504

    ### GONE Type: `int` Value:
        410

    ### HTTP_VERSION_NOT_SUPPORTED Type: `int` Value:
        505

    ### INSUFFICIENT_STORAGE_SPACE Type: `int` Value:
        507

    ### INTERNAL_SERVER_ERROR Type: `int` Value:
        500

    ### LENGTH_REQUIRED Type: `int` Value:
        411

    ### monthname Type: `list` Value:
        [None, 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug']

    ### MOVED_PERMANENTLY Type: `int` Value:
        301

    ### MULTI_STATUS Type: `int` Value:
        207

    ### MULTIPLE_CHOICE Type: `int` Value:
        300

    ### NO_BODY_CODES Type: `tuple` Value:
        (204, 304)

    ### NO_CONTENT Type: `int` Value:
        204

    ### NON_AUTHORITATIVE_INFORMATION Type: `int` Value:
        203

    ### NOT_ACCEPTABLE Type: `int` Value:
        406

    ### NOT_ALLOWED Type: `int` Value:
        405

    ### NOT_EXTENDED Type: `int` Value:
        510

    ### NOT_FOUND Type: `int` Value:
        404

    ### NOT_IMPLEMENTED Type: `int` Value:
        501

    ### NOT_MODIFIED Type: `int` Value:
        304

    ### OK Type: `int` Value:
        200

    ### PARTIAL_CONTENT Type: `int` Value:
        206

    ### PAYMENT_REQUIRED Type: `int` Value:
        402

    ### PRECONDITION_FAILED Type: `int` Value:
        412

    ### protocol_version Type: `str` Value:
        'HTTP/1.1'

    ### PROXY_AUTH_REQUIRED Type: `int` Value:
        407

    ### REQUEST_ENTITY_TOO_LARGE Type: `int` Value:
        413

    ### REQUEST_TIMEOUT Type: `int` Value:
        408

    ### REQUEST_URI_TOO_LONG Type: `int` Value:
        414

    ### REQUESTED_RANGE_NOT_SATISFIABLE Type: `int` Value:
        416

    ### RESET_CONTENT Type: `int` Value:
        205

    ### responses Type: `dict` Value:
        {100: 'Continue',
         101: 'Switching Protocols',
         200: 'OK',
         201: 'Created',
         202: 'Accepted',
         203: 'Non-Authoritative Information',
         204: 'No Content',
         205: 'Reset Content.',
        ...

    ### RESPONSES Type: `dict` Value:
        {100: 'Continue',
         101: 'Switching Protocols',
         200: 'OK',
         201: 'Created',
         202: 'Accepted',
         203: 'Non-Authoritative Information',
         204: 'No Content',
         205: 'Reset Content.',
        ...

    ### SEE_OTHER Type: `int` Value:
        303

    ### SERVICE_UNAVAILABLE Type: `int` Value:
        503

    ### SWITCHING Type: `int` Value:
        101

    ### TEMPORARY_REDIRECT Type: `int` Value:
        307

    ### UNAUTHORIZED Type: `int` Value:
        401

    ### UNSUPPORTED_MEDIA_TYPE Type: `int` Value:
        415

    ### USE_PROXY Type: `int` Value:
        305

    ### weekdayname Type: `list` Value:
        ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']

Generated by Epydoc 2.0 on Sat Oct 25 00:54:58 2003 | http://epydoc.sf.net