Skip to content

Commit 83fea2b

Browse files
committed
interesting
1 parent d5eeb0e commit 83fea2b

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

labapp/app/app.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ def manip2():
323323
raise LabException("Ephemeral NS not set")
324324
base_url = app.config['base_url']
325325
url = f"https://{ns}.{base_url}/"
326-
t_headers = {"x-mcn-namespace": ns,"x-mcn-src-site": app.config["ce_info"]["site_name"]}
326+
t_headers = { "x-mcn-namespace": ns, "x-mcn-src-site": app.config["ce_info"]["site_name"]}
327327
r_data = cloudapp_req_headers(s, url, 7, t_headers)
328328
return jsonify(status='success', data=r_data)
329329
except (LabException, requests.RequestException, ValueError) as e:

labapp/app/fetch.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from requests.structures import CaseInsensitiveDict
2+
13
def headers_cleaner(headers):
24
"""
35
Remove headers that contain specific substrings.
@@ -34,9 +36,11 @@ def cloudapp_req_headers(session, url, timeout, headers):
3436
response = session.get(url, timeout=timeout)
3537
response.raise_for_status()
3638
data = response.json()
39+
req_headers = CaseInsensitiveDict(data['request_headers'])
3740
print(data)
3841
for header in headers:
39-
if header.lower() not in data['request_headers']:
42+
head_value = req_headers.get(header)
43+
if not head_value:
4044
raise ValueError(f"Header {header} not found request headers.")
4145
clean_headers = headers_cleaner(data['request_headers'])
4246
data['request_headers'] = clean_headers

0 commit comments

Comments
 (0)