Working with web sites

N.B. The HTTPHandler class has been present in the logging package since the first release, but was enhanced for Python 3.2 to add options for secure connections and user credentials. You may wish to use this version with earlier Python releases.

class logutils.http.HTTPHandler(host, url, method='GET', secure=False, credentials=None)

A class which sends records to a Web server, using either GET or POST semantics.

  • host – The Web server to connect to.
  • url – The URL to use for the connection.
  • method – The HTTP method to use. GET and POST are supported.
  • secure – set to True if HTTPS is to be used.
  • credentials – Set to a username/password tuple if desired. If set, a Basic authentication header is sent. WARNING: if using credentials, make sure secure is True to avoid sending usernames and passwords in cleartext over the wire.

Emit a record.

Send the record to the Web server as a percent-encoded dictionary

Parameters:record – The record to be emitted.

Default implementation of mapping the log record into a dict that is sent as the CGI data. Overwrite in your class. Contributed by Franz Glasner.

Parameters:record – The record to be mapped.