Package flumotion :: Package component :: Package misc :: Package httpserver :: Package httpcached :: Module http_client :: Class StreamGetter
[hide private]

Class StreamGetter

source code

             twisted.internet.protocol.Factory --+    
                                                 |    
           twisted.internet.protocol.ClientFactory --+
                                                     |
twisted.internet.protocol.BaseProtocol --+           |
                                         |           |
        twisted.internet.protocol.Protocol --+       |
                                             |       |
   twisted.protocols.basic._PauseableMixin --+       |
                                             |       |
          twisted.protocols.basic.LineReceiver --+   |
                                                 |   |
                       twisted.web.http.HTTPClient --+
                                                     |
                           extern.log.log.Loggable --+
                                                     |
                                                    StreamGetter

Retrieves a stream using HTTP 1.0.

This class is at the same time a Factory and a Protocol, this can be done because it's a client and in twisted client factories only create on protocol.

The outcome, the stream info and stream data is forwarded to a common.StreamConsumer instance given at creating time.

It supports range requests and some conditional request types (ifModified and ifUnmodified).

Instance Methods [hide private]
 
__init__(self, consumer, url, ifModifiedSince=None, ifUnmodifiedSince=None, start=None, size=None, timeout=0) source code
 
__repr__(self) source code
 
connect(self, proxyAddress=None, proxyPort=None, timeout=0) source code
 
pause(self) source code
 
resume(self) source code
 
cancel(self) source code
 
buildProtocol(self, addr)
Create an instance of a subclass of Protocol.
source code
 
clientConnectionFailed(self, connector, reason)
Called when a connection has failed to connect.
source code
 
connectionMade(self)
Called when a connection is made.
source code
 
connectionLost(self, reason)
Called when the connection is shut down.
source code
 
handleStatus(self, version, status_str, message)
Called when the status-line is received.
source code
 
handleHeader(self, key, val)
Called every time a header is received.
source code
 
handleEndHeaders(self)
Called when all headers have been received.
source code
 
handleResponsePart(self, data) source code
 
handleResponseEnd(self)
The response has been completely received.
source code
 
sendCommand(self, command, path) source code
 
_keepActive(self) source code
 
_resetIdleCheck(self) source code
 
_cancelIdleCheck(self) source code
 
_onIdleCheck(self) source code
 
_onTimeout(self) source code
 
_cancel(self) source code
 
_serverError(self, code, message) source code
 
_conditionFail(self, code, message) source code
 
_streamNotAvailable(self, code, message) source code
 
_onInfo(self, info) source code
 
_onData(self, data) source code
 
_streamDone(self) source code

Inherited from twisted.internet.protocol.ClientFactory: clientConnectionLost, startedConnecting

Inherited from twisted.internet.protocol.Factory: __providedBy__, __provides__, doStart, doStop, logPrefix, startFactory, stopFactory

Inherited from twisted.web.http.HTTPClient: endHeaders, extractHeader, lineReceived, rawDataReceived, sendHeader

Inherited from twisted.protocols.basic.LineReceiver: clearLineBuffer, dataReceived, lineLengthExceeded, sendLine, setLineMode, setRawMode

Inherited from twisted.internet.protocol.BaseProtocol: makeConnection

Inherited from twisted.protocols.basic._PauseableMixin: pauseProducing, resumeProducing, stopProducing

Inherited from extern.log.log.Loggable: debug, doLog, error, info, log, logFunction, logObjectName, warning, warningFailure, writeMarker

Class Variables [hide private]
  logCategory = 'stream-provider'
Implementors can provide a category to log their messages under.
  HTTP_METHOD = 'GET'
  host = None
hash(x)
  port = None
hash(x)

Inherited from twisted.internet.protocol.Factory: __implemented__, noisy, numPorts, protocol

Inherited from twisted.protocols.basic.LineReceiver: MAX_LENGTH, delimiter, line_mode

Inherited from twisted.internet.protocol.BaseProtocol: connected, transport

Inherited from twisted.protocols.basic._PauseableMixin: paused

Instance Variables [hide private]

Inherited from twisted.web.http.HTTPClient: firstLine, length

Inherited from twisted.web.http.HTTPClient (private): _header

Method Details [hide private]

buildProtocol(self, addr)

source code 

Create an instance of a subclass of Protocol.

The returned instance will handle input on an incoming server connection, and an attribute "factory" pointing to the creating factory.

Override this method to alter how Protocol instances get created.

Parameters:
  • addr - an object implementing twisted.internet.interfaces.IAddress
Overrides: twisted.internet.protocol.Factory.buildProtocol
(inherited documentation)

clientConnectionFailed(self, connector, reason)

source code 

Called when a connection has failed to connect.

It may be useful to call connector.connect() - this will reconnect.

Overrides: twisted.internet.protocol.ClientFactory.clientConnectionFailed
(inherited documentation)

connectionMade(self)

source code 

Called when a connection is made.

This may be considered the initializer of the protocol, because it is called when the connection is completed. For clients, this is called once the connection to the server has been established; for servers, this is called after an accept() call stops blocking and a socket has been received. If you need to send any greeting or initial message, do it here.

Overrides: twisted.internet.protocol.BaseProtocol.connectionMade
(inherited documentation)

connectionLost(self, reason)

source code 

Called when the connection is shut down.

Clear any circular references here, and any external references to this Protocol. The connection has been closed.

Overrides: twisted.internet.protocol.Protocol.connectionLost
(inherited documentation)

handleStatus(self, version, status_str, message)

source code 

Called when the status-line is received.

Parameters:
  • version - e.g. 'HTTP/1.0'
  • status - e.g. '200'
  • message - e.g. 'OK'
Overrides: twisted.web.http.HTTPClient.handleStatus
(inherited documentation)

handleHeader(self, key, val)

source code 

Called every time a header is received.

Overrides: twisted.web.http.HTTPClient.handleHeader
(inherited documentation)

handleEndHeaders(self)

source code 

Called when all headers have been received.

Overrides: twisted.web.http.HTTPClient.handleEndHeaders
(inherited documentation)

handleResponsePart(self, data)

source code 
Overrides: twisted.web.http.HTTPClient.handleResponsePart

handleResponseEnd(self)

source code 

The response has been completely received.

This callback may be invoked more than once per request.

Overrides: twisted.web.http.HTTPClient.handleResponseEnd
(inherited documentation)

sendCommand(self, command, path)

source code 
Overrides: twisted.web.http.HTTPClient.sendCommand