set headers instead of adding to headers

This commit is contained in:
Ryan Heise 2020-06-09 12:20:45 +10:00
parent 030d9f83a3
commit 64eda2b65b
1 changed files with 6 additions and 1 deletions

View File

@ -652,7 +652,12 @@ class _ProxyHttpServer {
final proxyRequest = _uriMap[path]; final proxyRequest = _uriMap[path];
final originRequest = await HttpClient().getUrl(proxyRequest.uri); final originRequest = await HttpClient().getUrl(proxyRequest.uri);
for (var name in proxyRequest.headers.keys) { for (var name in proxyRequest.headers.keys) {
originRequest.headers.add(name, proxyRequest.headers[name]); final value = proxyRequest.headers[name];
if (value != null) {
originRequest.headers.set(name, value);
} else {
originRequest.headers.removeAll(name);
}
} }
final originResponse = await originRequest.close(); final originResponse = await originRequest.close();
await originResponse.pipe(request.response); await originResponse.pipe(request.response);