summaryrefslogtreecommitdiff
path: root/http.go
diff options
context:
space:
mode:
authorNathan Johnson <[email protected]>2018-06-07 17:11:22 -0500
committerBrad Fitzpatrick <[email protected]>2018-06-07 15:11:22 -0700
commitdbc151467a20b4513174bb3d6b1283e9419eb0f9 (patch)
tree3ee70fb558b3c4ec256dbb030eb069699dd40c84 /http.go
parent2b928d9b07d782cc1a94736979d012792810658f (diff)
Adding the HostName field to the Conn struct (#18)
Changing the internal-only match interface to return any parsed hostnames. It can be useful for implementers of Target to be able to inspect the already-parsed SNI header (in the case of TLS) or host header (in the case of http) to know what host was asked for by the client in order to make additional routing decisions. This can be used by transparent reverse proxies where the destination is not known in advance.
Diffstat (limited to 'http.go')
-rw-r--r--http.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/http.go b/http.go
index 6197da9..d28c66f 100644
--- a/http.go
+++ b/http.go
@@ -46,11 +46,12 @@ type httpHostMatch struct {
target Target
}
-func (m httpHostMatch) match(br *bufio.Reader) Target {
- if m.matcher(context.TODO(), httpHostHeader(br)) {
- return m.target
+func (m httpHostMatch) match(br *bufio.Reader) (Target, string) {
+ hh := httpHostHeader(br)
+ if m.matcher(context.TODO(), hh) {
+ return m.target, hh
}
- return nil
+ return nil, ""
}
// httpHostHeader returns the HTTP Host header from br without