-
Notifications
You must be signed in to change notification settings - Fork 235
/
azure.core.pipeline.policies.HeadersPolicy.yml
101 lines (95 loc) · 4.15 KB
/
azure.core.pipeline.policies.HeadersPolicy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
### YamlMime:PythonClass
uid: azure.core.pipeline.policies.HeadersPolicy
name: HeadersPolicy
fullName: azure.core.pipeline.policies.HeadersPolicy
module: azure.core.pipeline.policies
inheritances:
- azure.core.pipeline.policies._base.SansIOHTTPPolicy
summary: 'A simple policy that sends the given headers with the request.
This will overwrite any headers already defined in the request. Headers can be
configured up front, where any custom headers will be applied to all outgoing
operations, and additional headers can also be added dynamically per operation.'
constructor:
syntax: 'HeadersPolicy(base_headers: Dict[str, str] | None = None, **kwargs: Any)'
parameters:
- name: base_headers
description: Headers to send with the request.
defaultValue: None
types:
- <xref:dict>
examples:
- "Configuring a headers policy.<!--[!code-python[Main](les\\test_example_sansio.py\
\ )]-->\n\n<!-- literal_block {\"ids\": [], \"classes\": [], \"names\": [], \"dupnames\"\
: [], \"backrefs\": [], \"source\": \"C:\\\\hostedtoolcache\\\\windows\\\\Python\\\
\\3.11.9\\\\x64\\\\Lib\\\\site-packages\\\\py2docfx\\\\dist_temp\\\\35\\\\azure-core-1.30.2\\\
\\samples\\\\test_example_sansio.py\", \"xml:space\": \"preserve\", \"force\": false,\
\ \"language\": \"python\", \"highlight_args\": {\"linenostart\": 1}, \"linenos\"\
: false} -->\n\n````python\n\n from azure.core.pipeline.policies import HeadersPolicy\n\
\n headers_policy = HeadersPolicy()\n headers_policy.add_header(\"CustomValue\"\
, \"Foo\")\n\n # Or headers can be added per operation. These headers will supplement\
\ existing headers\n # or those defined in the config headers policy. They will\
\ also overwrite existing\n # identical headers.\n policies.append(headers_policy)\n\
\ client: PipelineClient[HttpRequest, HttpResponse] = PipelineClient(base_url=url,\
\ policies=policies)\n request = HttpRequest(\"GET\", url)\n pipeline_response\
\ = client._pipeline.run(request, headers={\"CustomValue\": \"Bar\"})\n\n ````\n"
methods:
- uid: azure.core.pipeline.policies.HeadersPolicy.add_header
name: add_header
summary: Add a header to the configuration to be applied to all requests.
signature: 'add_header(key: str, value: str) -> None'
parameters:
- name: key
description: The header.
isRequired: true
types:
- <xref:str>
- name: value
description: The header's value.
isRequired: true
types:
- <xref:str>
- uid: azure.core.pipeline.policies.HeadersPolicy.on_exception
name: on_exception
summary: 'Is executed if an exception is raised while executing the next policy.
This method is executed inside the exception handler.'
signature: 'on_exception(request: PipelineRequest[HTTPRequestType]) -> None'
parameters:
- name: request
description: The Pipeline request object
isRequired: true
types:
- <xref:azure.core.pipeline.PipelineRequest>
- uid: azure.core.pipeline.policies.HeadersPolicy.on_request
name: on_request
summary: Updates with the given headers before sending the request to the next policy.
signature: 'on_request(request: PipelineRequest[HttpRequest | HttpRequest]) -> None'
parameters:
- name: request
description: The PipelineRequest object
isRequired: true
types:
- <xref:azure.core.pipeline.PipelineRequest>
- uid: azure.core.pipeline.policies.HeadersPolicy.on_response
name: on_response
summary: Is executed after the request comes back from the policy.
signature: 'on_response(request: PipelineRequest[HTTPRequestType], response: PipelineResponse[HTTPRequestType,
HTTPResponseType]) -> None | Awaitable[None]'
parameters:
- name: request
description: Request to be modified after returning from the policy.
isRequired: true
types:
- <xref:azure.core.pipeline.PipelineRequest>
- name: response
description: Pipeline response object
isRequired: true
types:
- <xref:azure.core.pipeline.PipelineResponse>
attributes:
- uid: azure.core.pipeline.policies.HeadersPolicy.headers
name: headers
summary: The current headers collection.
return:
description: The current headers collection.
types:
- <xref:dict>[<xref:str>, <xref:str>]