@@ -20,6 +20,18 @@ def is_mirror():
20
20
return bool (cfg .get ('mirroring' , False ))
21
21
22
22
23
+ def _response_headers (base ):
24
+ headers = {}
25
+ if not base :
26
+ return headers
27
+ for k , v in base .iteritems ():
28
+ if k .lower () == 'content-encoding' :
29
+ continue
30
+ headers [k .lower ()] = v
31
+ logger .warn (headers )
32
+ return headers
33
+
34
+
23
35
def lookup_source (path , stream = False , source = None ):
24
36
if not source :
25
37
cfg = config .load ()
@@ -79,10 +91,7 @@ def wrapper(namespace, repository, *args, **kwargs):
79
91
if not source_resp :
80
92
return resp
81
93
82
- headers = source_resp .headers
83
- if 'Content-Encoding' in headers :
84
- del headers ['Content-Encoding' ]
85
-
94
+ headers = _response_headers (source_resp .headers )
86
95
return toolkit .response (data = source_resp .content , headers = headers ,
87
96
raw = True )
88
97
@@ -107,10 +116,7 @@ def wrapper(namespace, repository, *args, **kwargs):
107
116
if not source_resp :
108
117
return resp
109
118
data = source_resp .content
110
- headers = source_resp .headers
111
- if 'Content-Encoding' in headers :
112
- del headers ['Content-Encoding' ]
113
-
119
+ headers = _response_headers (source_resp .headers )
114
120
cache .redis_conn .setex ('{0}:{1}' .format (
115
121
cache .cache_prefix , tag_path
116
122
), tags_cache_ttl , data )
@@ -144,11 +150,9 @@ def wrapper(*args, **kwargs):
144
150
145
151
store = storage .load ()
146
152
147
- headers = source_resp .headers
148
- if 'Content-Encoding' in headers :
149
- del headers ['Content-Encoding' ]
150
- if index_route and 'X-Docker-Endpoints' in headers :
151
- headers ['X-Docker-Endpoints' ] = toolkit .get_endpoints ()
153
+ headers = _response_headers (source_resp .headers )
154
+ if index_route and 'x-docker-endpoints' in headers :
155
+ headers ['x-docker-endpoints' ] = toolkit .get_endpoints ()
152
156
153
157
if not stream :
154
158
logger .debug ('JSON data found on source, writing response' )
0 commit comments