Request Headers#
The request headers plugin hook allows plugin authors to add custom HTTP
headers to HTTP requests within conda. This works by attaching these headers to
our internal CondaSession
class.
When defining these headers via the CondaRequestHeader
class,
you can optionally define a hosts
parameter. This is a set of strings
representing the different hostnames for which you want the custom headers to be submitted
to. When this is not defined, the custom HTTP headers will be submitted for all hostnames.
- class CondaRequestHeader#
Define vendor specific headers to include HTTP requests
For details on how this is used, see
conda_request_headers()
.- Parameters:
name -- name of the header used in the HTTP request
description -- description of the HTTP header and its purpose
value -- value of the header used in the HTTP request
hosts -- host(s) for which this header should be used with; when not set the header will be included in all HTTP requests.
- description#
- hosts#
- name#
- value#
- conda_request_headers()#
Register new HTTP request headers
The example below defines how to add HTTP headers for all requests with the hostname of
example.com
Example:
from conda import plugins @plugins.hookimpl def conda_request_headers(): yield plugins.CondaRequestHeader( name="Example-Header", description="This is an example HTTP header", value="example", hosts={"example.com", "sub.example.com"}, )