mgkit.net.utils module

Utility functions for the network package

mgkit.net.utils.url_open(url, data=None, compress=True, agent=None)

Utility function that compresses the request and add the user agent header if supplied.

Parameters:
  • url (str) – url to request
  • data (str) – data to add to the request
  • compress (bool) – if the response should be compressed
  • agent (str) – if supplied, the ‘User-Agent’ header we’ll be added to the request
Returns:

the response handle

mgkit.net.utils.url_read(url, data=None, compress=True, agent=None)

Utility function that compresses the request and add the user agent header if supplied.

Wrapper of url_open() which reads the full response

Parameters:
  • url (str) – url to request
  • data (str) – data to add to the request
  • compress (bool) – if the response should be compressed
  • agent (str) – if supplied, the ‘User-Agent’ header we’ll be added to the request
Returns:

the response data