From 792dd09a873464c7b24cf962b0b3e633d67477d2 Mon Sep 17 00:00:00 2001 From: Hubert Tarasiuk Date: Mon, 22 Jun 2015 20:46:01 +0200 Subject: [PATCH] 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. --- testenv/README | 3 ++- testenv/server/http/http_server.py | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/testenv/README b/testenv/README index cf22f894..50baf3d6 100644 --- a/testenv/README +++ b/testenv/README @@ -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 request for the respective file. It follows the same value format as - ExpectHeader. + ExpectHeader. Additionally you can specify a list of strings as
+ if you want the header repeated with multiple values. * 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. diff --git a/testenv/server/http/http_server.py b/testenv/server/http/http_server.py index 2356f1c2..85769c43 100644 --- a/testenv/server/http/http_server.py +++ b/testenv/server/http/http_server.py @@ -191,7 +191,11 @@ class _Handler(BaseHTTPRequestHandler): self.send_cust_headers() try: for keyword, value in self._headers_dict.items(): - self.send_header(keyword, value) + if isinstance(value, list): + for value_el in value: + self.send_header(keyword, value_el) + else: + self.send_header(keyword, value) # Clear the dictionary of existing headers for the next request self._headers_dict.clear() except AttributeError: