summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorjonathonf <j.fernyhough@gmail.com>2015-08-01 20:53:37 +0100
committerjonathonf <j.fernyhough@gmail.com>2015-08-01 20:53:37 +0100
commit9dde0ae3ac6c97704f64e0dee0d55c1a49faaf4b (patch)
tree27dd23c41c56a60a5931f7f63ee5e41dd6db9490 /lib
parent92ca736f0ac2e3b8c66516fb22ce8c5fbdac69d5 (diff)
downloadNim-9dde0ae3ac6c97704f64e0dee0d55c1a49faaf4b.tar.gz
Set correct Host in request header

Ensure the correct destination hostname is used in the request, otherwise the request will fail in one of a number of interesting ways when using a proxy.

Fixes https://github.com/nim-lang/Nim/issues/3166
Diffstat (limited to 'lib')
-rw-r--r--lib/pure/httpclient.nim2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/pure/httpclient.nim b/lib/pure/httpclient.nim
index e6b8088c5..98687359b 100644
--- a/lib/pure/httpclient.nim
+++ b/lib/pure/httpclient.nim
@@ -402,7 +402,7 @@ proc request*(url: string, httpMethod: string, extraHeaders = "",
 
   headers.add(" HTTP/1.1\c\L")
 
-  add(headers, "Host: " & r.hostname & "\c\L")
+  add(headers, "Host: " & parseUri(url).hostname & "\c\L")
   if userAgent != "":
     add(headers, "User-Agent: " & userAgent & "\c\L")
   if proxy != nil and proxy.auth != "":
d3'>^
dce8949b9 ^
8d99753d6 ^
7000cf51b ^

dd99fe61c ^
12f22ba68 ^
8d99753d6 ^

2f066395b ^
12f22ba68 ^


7000cf51b ^
dce8949b9 ^
12f22ba68 ^
2f066395b ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33