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