-
Notifications
You must be signed in to change notification settings - Fork 493
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* grpc server * - add grpc-server.md - fix bug: gRPC only support ip/hostname:port * fix loadbalance unit test * gRPC func Host will return port, some cases only need host without port * fix unit test * follow up the suggestions
- Loading branch information
Showing
9 changed files
with
131 additions
and
58 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,7 @@ type ( | |
realIP string | ||
sts *serverTransportStream | ||
peer *peer.Peer | ||
host string | ||
} | ||
|
||
serverTransportStream struct { | ||
|
@@ -272,14 +273,32 @@ func (r *Request) SetSourceHost(sourceHost string) { | |
} | ||
|
||
// Host refer to google.golang.org\[email protected]\internal\transport\http2_server.go#operateHeaders | ||
// ensure only one value | ||
// It may be of the form "host:port" or contain an international domain name. | ||
func (r *Request) Host() string { | ||
return r.header.GetFirst(Authority) | ||
} | ||
|
||
// OnlyHost return host or hostname without port | ||
func (r *Request) OnlyHost() string { | ||
if r.host != "" { | ||
return r.host | ||
} | ||
host := r.Host() | ||
if h, _, err := net.SplitHostPort(host); err == nil { | ||
host = h | ||
} | ||
r.host = host | ||
return host | ||
} | ||
|
||
// SetHost set the host of the request. | ||
func (r *Request) SetHost(host string) { | ||
r.header.Set(Authority, host) | ||
if h, _, err := net.SplitHostPort(host); err == nil { | ||
r.host = h | ||
} else { | ||
r.host = host | ||
} | ||
} | ||
|
||
// Header returns the header of the request in type protocols.Header. | ||
|