5.3.2. vlcp.protocol.http¶
Note
This document is generated from the source file.
Created on 2015/8/18
| author: | hubo |
|---|
-
class
vlcp.protocol.http.Http(server=True, defaultversion=None)¶ Basic HTTP/1.1 protocol Base on RFC723x, which are more strict than RFC2616
-
__init__(server=True, defaultversion=None)¶ Constructor
-
beforelisten(tcpserver, newsock)¶ routine before a socket entering listen mode
-
closed(connection)¶ routine for connection closed
-
error(connection)¶ routine for connection error
-
final(connection)¶ routine for a connection finally ends: all connections are closed and not retrying
-
init(connection)¶ routine for connection initialization
-
notconnected(connection)¶ routine for connect failed and not retrying
-
parse(connection, data, laststart)¶ Parse input data into events
Parameters: - connection – connection object
- data – view for input data
- laststart – last parsed position
Returns: (events, keep) where events are parsed events to send, keep is the unused data length to be keeped for next parse.
-
reconnect_init(connection)¶ routine for reconnect
-
request_with_response(container, connection, host, path=b'/', method=b'GET', headers=[], stream=None, keepalive=True)¶ Send a HTTP request, and wait for the response. The last (usually wanted) response is stored in http_finalresponse. There may be multiple responses (1xx) for this request, they are stored in http_responses
Returns: (http_finalresponse, http_responses)
-
requestwithresponse(container, connection, host, path=b'/', method=b'GET', headers=[], stream=None, keepalive=True)¶ Send a HTTP request, and wait for the response. The last (usually wanted) response is stored in http_finalresponse. There may be multiple responses (1xx) for this request, they are stored in http_responses
Returns: (http_finalresponse, http_responses)
-
responseTo(connection, xid, response)¶ Return an event if notify is necessary
-
response_to(connection, xid, response)¶ Return an event if notify is necessary
-
responsematcher(connection, xid, isfinal=None, iserror=None)¶ Create an event matcher to match the response
-
sendRequest(connection, host, path=b'/', method=b'GET', headers=[], stream=None, keepalive=True)¶ If you do not provide a content-length header, the stream will be transfer-encoded with chunked, and it is not always acceptable by servers.
You may provide a MemoryStream, and it will provide a content-length header automatically
Return xid
-
send_request(connection, host, path=b'/', method=b'GET', headers=[], stream=None, keepalive=True)¶ If you do not provide a content-length header, the stream will be transfer-encoded with chunked, and it is not always acceptable by servers.
You may provide a MemoryStream, and it will provide a content-length header automatically
Return xid
-
serverfinal(tcpserver)¶ routine for a tcpserver finally shutdown or not connected
-
startResponse(connection, xid, status, headers, outputstream, disabledeflate=False)¶ Start to response to a request with the specified xid on the connection, with status code and headers. The output stream is used to output the response body.
-
start_response(connection, xid, status, headers, outputstream, disabledeflate=False)¶ Start to response to a request with the specified xid on the connection, with status code and headers. The output stream is used to output the response body.
-
statematcher(connection, state='clientclose', currentconn=True)¶ Create an event matcher to match the connection state
-
-
exception
vlcp.protocol.http.HttpConnectionClosedException¶ Connection is closed
-
class
vlcp.protocol.http.HttpConnectionStateEvent(*args, **kwargs)¶ HTTP connection state changed
-
exception
vlcp.protocol.http.HttpProtocolException¶ Critical protocol break on HTTP connections
-
class
vlcp.protocol.http.HttpRequestEvent(*args, **kwargs)¶ A HTTP request is received from the connection
-
canignorenow()¶ Extra criteria for an event with canignore = False. When this event returns True, the event is safely ignored.
-
-
class
vlcp.protocol.http.HttpResponseEndEvent(*args, **kwargs)¶ A HTTP response is fully received
-
class
vlcp.protocol.http.HttpResponseEvent(*args, **kwargs)¶ A HTTP response is received from the connection
-
class
vlcp.protocol.http.HttpStateChange(*args, **kwargs)¶
-
class
vlcp.protocol.http.HttpTrailersReceived(*args, **kwargs)¶ Trailers are received on an HTTPResponseStream
-
vlcp.protocol.http.date_time_string(timestamp=None)¶ Return the current date and time formatted for a message header.
-
vlcp.protocol.http.escape(s, quote=True)¶ Replace special characters “&”, “<” and “>” to HTML-safe sequences. If the optional flag quote is true, the quotation mark character (“) is also translated.
-
vlcp.protocol.http.escape_b(s, quote=True)¶ Replace special characters “&”, “<” and “>” to HTML-safe sequences. If the optional flag quote is true, the quotation mark character (“) is also translated.