1
0
mirror of https://github.com/moparisthebest/wget synced 2024-07-03 16:38:41 -04:00

Support multiple headers with same name in Python test suite.

* testenv/README: Describe how to use repeated header name.
* testenv/server/http/http_server.py (finish_headers): Send all
values from list if the header value is a Python list.
This commit is contained in:
Hubert Tarasiuk 2015-06-22 20:46:01 +02:00 committed by Giuseppe Scrivano
parent a4f5ced797
commit 792dd09a87
2 changed files with 7 additions and 2 deletions

View File

@ -184,7 +184,8 @@ This section lists the currently supported File Rules and their structure.
* SendHeader : This list of Headers will be sent in EVERY response to a * SendHeader : This list of Headers will be sent in EVERY response to a
request for the respective file. It follows the same value format as request for the respective file. It follows the same value format as
ExpectHeader. ExpectHeader. Additionally you can specify a list of strings as <Header Data>
if you want the header repeated with multiple values.
* Response : The HTTP Response Code to send to a request for this File. * Response : The HTTP Response Code to send to a request for this File.
The value is an Integer that represents a valid HTTP Response Code. The value is an Integer that represents a valid HTTP Response Code.

View File

@ -191,6 +191,10 @@ class _Handler(BaseHTTPRequestHandler):
self.send_cust_headers() self.send_cust_headers()
try: try:
for keyword, value in self._headers_dict.items(): for keyword, value in self._headers_dict.items():
if isinstance(value, list):
for value_el in value:
self.send_header(keyword, value_el)
else:
self.send_header(keyword, value) self.send_header(keyword, value)
# Clear the dictionary of existing headers for the next request # Clear the dictionary of existing headers for the next request
self._headers_dict.clear() self._headers_dict.clear()