| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library shelf_proxy; | |
| 6 | |
| 7 import 'package:http/http.dart' as http; | 5 import 'package:http/http.dart' as http; |
| 8 import 'package:path/path.dart' as p; | 6 import 'package:path/path.dart' as p; |
| 9 import 'package:shelf/shelf.dart'; | 7 import 'package:shelf/shelf.dart'; |
| 10 | 8 |
| 11 import 'src/utils.dart'; | 9 import 'src/utils.dart'; |
| 12 | 10 |
| 13 /// A handler that proxies requests to [url]. | 11 /// A handler that proxies requests to [url]. |
| 14 /// | 12 /// |
| 15 /// To generate the proxy request, this concatenates [url] and [Request.url]. | 13 /// To generate the proxy request, this concatenates [url] and [Request.url]. |
| 16 /// This means that if the handler mounted under `/documentation` and [url] is | 14 /// This means that if the handler mounted under `/documentation` and [url] is |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 // TODO(nweiz): use built-in methods for this when http and shelf support them. | 92 // TODO(nweiz): use built-in methods for this when http and shelf support them. |
| 95 /// Add a header with [name] and [value] to [headers], handling existing headers | 93 /// Add a header with [name] and [value] to [headers], handling existing headers |
| 96 /// gracefully. | 94 /// gracefully. |
| 97 void _addHeader(Map<String, String> headers, String name, String value) { | 95 void _addHeader(Map<String, String> headers, String name, String value) { |
| 98 if (headers.containsKey(name)) { | 96 if (headers.containsKey(name)) { |
| 99 headers[name] += ', $value'; | 97 headers[name] += ', $value'; |
| 100 } else { | 98 } else { |
| 101 headers[name] = value; | 99 headers[name] = value; |
| 102 } | 100 } |
| 103 } | 101 } |
| OLD | NEW |