authcaptureproxy.helper

Python Package for auth capture proxy.

Helper files.

Module Contents

authcaptureproxy.helper.print_resp(resp: Union[httpx.Response, aiohttp.ClientResponse])None

Print response info.

Parameters

resp (httpx.Response) – The client response to show

Returns

None

authcaptureproxy.helper.print_resp_aiohttp(resp: aiohttp.ClientResponse)None

Print response info.

Parameters

resp (ClientResponse) – The client response to show

Returns

None

async authcaptureproxy.helper.run_func(func: Callable, name: Text = '', *args, **kwargs)Any

Run any function or coroutine.

Parameters
  • func (Callable) – Func to run

  • name (Text, optional) – Name for function. Defaults to “”.

Returns

Result of running the function

Return type

Any

authcaptureproxy.helper.swap_url(ignore_query: bool = True, old_url: yarl.URL = URL(''), new_url: yarl.URL = URL(''), url: yarl.URL = URL(''))yarl.URL

Swap any instances of the old url with the new url. Will not replace query info.

Parameters
  • ignore_query (bool) – Whether the url.query should be ignored. Defaults to True.

  • old_url (URL) – Old url to find and replace. If there is any additional path, it will be added to the new_url.

  • new_url (URL) – New url to replace.

  • url (URL) – url to modify

authcaptureproxy.helper.prepend_url(base_url: yarl.URL, url: yarl.URL, encoded: bool = False)yarl.URL

Prepend the url.

Parameters
  • base_url (URL) – Base URL to prepend

  • url (URL) – url to prepend

  • encoded (bool) – Whether to treat the url as already encoded. This may be needed if the url is JavaScript.

authcaptureproxy.helper.replace_empty_url(new_url: yarl.URL, url: yarl.URL)yarl.URL

Replace the empty url with new_url if and only if empty.

Parameters
  • new_url (URL) – New URL to use if url is blank

  • url (URL) – url to replace if empty

authcaptureproxy.helper.get_nested_dict_keys(nested_dict: Mapping[Text, Union[Callable, Dict[Text, Callable]]])List[Text]

Get list of nested dict keys.

Parameters

nested_dict (Mapping[Text, Union[Callable, Dict[Text, Callable]]]) – The dictionary to parse.

Returns

List of keys from dictionary.

Return type

List[Text]

authcaptureproxy.helper.get_content_type(resp: httpx.Response)str

Get content_type from httpx Response.

Parameters

resp (httpx.Response) – Response from httpx request

Returns

The content_type

Return type

str

authcaptureproxy.helper.convert_multidict_to_dict(multidict: Union[multidict.MultiDict, multidict.MultiDictProxy], flat: bool = False)dict

Convert a multdict to a dict for httpx.

https://www.python-httpx.org/quickstart/#sending-form-encoded-data

Parameters
  • multidict (MultiDict | MultiDictProxy) – The multidict to convert

  • flat (bool) – whether to create a list for duplicates or keep last

Returns

A dictionary where duplicate keys will be added as a list or flattened

Return type

dict