WSGIStreamOut

This module defines a class for writing responses using WSGI.

exception WSGIStreamOut.InvalidCommandSequence

Bases: ConnectionError

Invalid command sequence error

__init__(*args, **kwargs)
args
characters_written
errno

POSIX exception code

filename

exception filename

filename2

second exception filename

strerror

exception strerror

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

class WSGIStreamOut.WSGIStreamOut(startResponse, autoCommit=False, bufferSize=8192, useWrite=True, encoding='utf-8')

Bases: object

This is a response stream to the client using WSGI.

The key attributes of this class are:

_startResponse:

The start_response() function that is part of the WSGI protocol.

_autoCommit:

If True, the stream will automatically start sending data once it has accumulated _bufferSize data. This means that it will ask the response to commit itself, without developer interaction. By default, this is set to False.

_bufferSize:

The size of the data buffer. This is only used when autocommit is True. If not using autocommit, the whole response is buffered and sent in one shot when the servlet is done.

_useWrite:

Whether the write callable that is returned by start_response() shall be used to deliver the response.

flush():

Send the accumulated response data now. Will ask the Response to commit if it hasn’t already done so.

__init__(startResponse, autoCommit=False, bufferSize=8192, useWrite=True, encoding='utf-8')
autoCommit()

Get the auto commit mode.

buffer()

Return accumulated data which has not yet been flushed.

We want to be able to get at this data without having to call flush() first, so that we can (for example) integrate automatic HTML validation.

bufferSize()

Get the buffer size.

clear()

Try to clear any accumulated response data.

Will fail if the response is already committed.

close()

Close this buffer. No more data may be sent.

closed()

Check whether we are closed to new data.

commit(autoCommit=True)

Called by the Response to tell us to go.

If _autoCommit is True, then we will be placed into autoCommit mode.

committed()

Check whether the outptu is already committed

flush()

Flush stream.

iterable()

Return the WSGI iterable.

needCommit()

Request for commitment.

Called by the HTTPResponse instance that is using this instance to ask if the response needs to be prepared to be delivered. The response should then commit its headers, etc.

pop(count)

Remove count bytes from the front of the buffer.

prepend(output)

Add the output to the front of the response buffer.

The output may be a byte string or anything that can be converted to a string and encoded to a byte string using the output encoding.

Invalid if we are already committed.

setAutoCommit(autoCommit=True)

Set the auto commit mode.

setBufferSize(bufferSize=8192)

Set the buffer size.

size()

Return the current size of the data held here.

startResponse(status, headers)

Start the response with the given status and headers.

write(output)

Write output to the buffer.

The output may be a byte string or anything that can be converted to a string and encoded to a byte string using the output encoding.