Package ganeti :: Package http
[hide private]
[frames] | no frames]

Package http

source code

HTTP module.

Submodules [hide private]

Classes [hide private]
  HttpError
Internal exception for HTTP errors.
  HttpConnectionClosed
Internal exception for a closed connection.
  HttpSessionHandshakeUnexpectedEOF
Internal exception for errors during SSL handshake.
  HttpSocketTimeout
Internal exception for socket timeouts.
  HttpException
  HttpBadRequest
400 Bad Request
  HttpUnauthorized
401 Unauthorized
  HttpForbidden
403 Forbidden
  HttpNotFound
404 Not Found
  HttpMethodNotAllowed
405 Method Not Allowed
  HttpNotAcceptable
406 Not Acceptable
  HttpRequestTimeout
408 Request Timeout
  HttpConflict
409 Conflict
  HttpGone
410 Gone
  HttpLengthRequired
411 Length Required
  HttpPreconditionFailed
412 Precondition Failed
  HttpUnsupportedMediaType
415 Unsupported Media Type
  HttpInternalServerError
500 Internal Server Error
  HttpNotImplemented
501 Not Implemented
  HttpBadGateway
502 Bad Gateway
  HttpServiceUnavailable
503 Service Unavailable
  HttpGatewayTimeout
504 Gateway Timeout
  HttpVersionNotSupported
505 HTTP Version Not Supported
  HttpSslParams
Data class for SSL key and certificate.
  HttpBase
Base class for HTTP server and client.
  HttpMessage
Data structure for HTTP message.
  HttpClientToServerStartLine
Data structure for HTTP request start line.
  HttpServerToClientStartLine
Data structure for HTTP response start line.
  HttpMessageWriter
Writes an HTTP message to a socket.
  HttpMessageReader
Reads HTTP message from socket.
Functions [hide private]
 
SocketOperation(sock, op, arg1, timeout)
Wrapper around socket functions.
source code
 
ShutdownConnection(sock, close_timeout, write_timeout, msgreader, force)
Closes the connection.
source code
 
Handshake(sock, write_timeout)
Shakes peer's hands.
source code
 
InitSsl()
Initializes the SSL infrastructure.
source code
Variables [hide private]
  HTTP_GANETI_VERSION = "Ganeti %s" % constants.RELEASE_VERSION
  HTTP_OK = 200
  HTTP_NO_CONTENT = 204
  HTTP_NOT_MODIFIED = 304
  HTTP_0_9 = "HTTP/0.9"
  HTTP_1_0 = "HTTP/1.0"
  HTTP_1_1 = "HTTP/1.1"
  HTTP_GET = "GET"
  HTTP_HEAD = "HEAD"
  HTTP_POST = "POST"
  HTTP_PUT = "PUT"
  HTTP_DELETE = "DELETE"
  HTTP_ETAG = "ETag"
  HTTP_HOST = "Host"
  HTTP_SERVER = "Server"
  HTTP_DATE = "Date"
  HTTP_USER_AGENT = "User-Agent"
  HTTP_CONTENT_TYPE = "Content-Type"
  HTTP_CONTENT_LENGTH = "Content-Length"
  HTTP_CONNECTION = "Connection"
  HTTP_KEEP_ALIVE = "Keep-Alive"
  HTTP_WWW_AUTHENTICATE = "WWW-Authenticate"
  HTTP_AUTHORIZATION = "Authorization"
  HTTP_AUTHENTICATION_INFO = "Authentication-Info"
  HTTP_ALLOW = "Allow"
  HTTP_APP_OCTET_STREAM = "application/octet-stream"
  HTTP_APP_JSON = "application/json"
  _SSL_UNEXPECTED_EOF = "Unexpected EOF"
  SOCK_BUF_SIZE = 32768

Imports: logging, mimetools, OpenSSL, select, socket, errno, StringIO, constants, utils


Function Details [hide private]

SocketOperation(sock, op, arg1, timeout)

source code 

Wrapper around socket functions.

This function abstracts error handling for socket operations, especially for the complicated interaction with OpenSSL.

Parameters:
  • sock (socket) - Socket for the operation
  • op (int) - Operation to execute (SOCKOP_* constants)
  • arg1 (any) - Parameter for function (if needed)
  • timeout (None or float) - Timeout in seconds or None
Returns:
Return value of socket function

ShutdownConnection(sock, close_timeout, write_timeout, msgreader, force)

source code 

Closes the connection.

Parameters:
  • sock (socket) - Socket to be shut down
  • close_timeout (float) - How long to wait for the peer to close the connection
  • write_timeout (float) - Write timeout for shutdown
  • msgreader (http.HttpMessageReader) - Request message reader, used to determine whether peer should close connection
  • force (bool) - Whether to forcibly close the connection without waiting for peer

Handshake(sock, write_timeout)

source code 

Shakes peer's hands.

Parameters:
  • sock (socket) - Socket to be shut down
  • write_timeout (float) - Write timeout for handshake

InitSsl()

source code 

Initializes the SSL infrastructure.

This function is idempotent.