sugar4.network

STABLE.

Classes

GlibTCPServer

GlibTCPServer

ChunkedGlibHTTPRequestHandler

RequestHandler class that integrates with Glib mainloop. It writes

GlibURLDownloader

Grabs a URL in chunks, returning to the mainloop after each chunk

Functions

get_authinfo()

Module Contents

sugar4.network.get_authinfo()[source]
class sugar4.network.GlibTCPServer(server_address, RequestHandlerClass)[source]

Bases: six.moves.socketserver.TCPServer

GlibTCPServer

Integrate socket accept into glib mainloop.

Constructor. May be extended, do not override.

allow_reuse_address = True[source]
request_queue_size = 20[source]
close_request(request)[source]

Called to clean up an individual request.

shutdown_request(request)[source]

Called to shutdown and close an individual request.

class sugar4.network.ChunkedGlibHTTPRequestHandler(request, client_address, server)[source]

Bases: six.moves.SimpleHTTPServer.SimpleHTTPRequestHandler

RequestHandler class that integrates with Glib mainloop. It writes the specified file to the client in chunks, returning control to the mainloop between chunks.

CHUNK_SIZE = 4096[source]
log_request(code='-', size='-')[source]
do_GET()[source]

Serve a GET request.

finish()[source]

Close the sockets when we’re done, not before

send_head()[source]

Common code for GET and HEAD commands.

This sends the response code and MIME headers.

Return value is either a file object (which has to be copied to the outputfile by the caller unless the command was HEAD, and must be closed by the caller under all circumstances), or None, in which case the caller has nothing further to do.

** [dcbw] modified to send Content-disposition filename too

class sugar4.network.GlibURLDownloader(url, destdir=None)[source]

Bases: gi.repository.GObject.GObject

Grabs a URL in chunks, returning to the mainloop after each chunk

__gsignals__[source]
CHUNK_SIZE = 4096[source]
start(destfile=None, destfd=None)[source]
cancel()[source]
cleanup(remove=False)[source]