-
Notifications
You must be signed in to change notification settings - Fork 186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix get host from req.header #39
base: master
Are you sure you want to change the base?
fix get host from req.header #39
Conversation
0a93a5e
to
3093ab4
Compare
ref: https://golang.org/pkg/net/http/#Request
|
// Constants for readRequest's deleteHostHeader parameter.
const (
deleteHostHeader = true
keepHostHeader = false
) and in // RFC 7230, section 5.3: Must treat
// GET /index.html HTTP/1.1
// Host: www.google.com
// and
// GET http://www.google.com/index.html HTTP/1.1
// Host: doesntmatter
// the same. In the second case, any Host line is ignored.
req.Host = req.URL.Host
if req.Host == "" {
req.Host = req.Header.get("Host")
}
if deleteHostHeader {
delete(req.Header, "Host")
} |
ref: request.go 218 // For server requests Host specifies the host on which the URL
219 // is sought. Per RFC 7230, section 5.4, this is either the value
220 // of the "Host" header or the host name given in the URL itself.
221 // It may be of the form "host:port". For international domain
222 // names, Host may be in Punycode or Unicode form. Use
223 // golang.org/x/net/idna to convert it to either format if
224 // needed.
225 // To prevent DNS rebinding attacks, server Handlers should
226 // validate that the Host header has a value for which the
227 // Handler considers itself authoritative. The included
228 // ServeMux supports patterns registered to particular host
229 // names and thus protects its registered Handlers.
230 //
231 // For client requests Host optionally overrides the Host
232 // header to send. If empty, the Request.Write method uses
233 // the value of URL.Host. Host may contain an international
234 // domain name.
235 Host string I think you should use |
ref: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Origin
Our target is to determine whether the request is same origin. So I think just determine whether the |
@liaojianqi please fix the conflicts. |
No description provided.