Comments (8)
Could you give some more details?
- What headers did you get when you used
http.ListenAndServeTLS
? - Where are these headers being printed from?
Thanks
from spdy.
Reverse-proxied headers sent to www.google.com when using http.ListenAndServeTLS
:
GET / HTTP/1.1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.131 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Cache-Control: max-age=0
X-Forwarded-For: 127.0.0.1
Host: www.google.com
I'm getting the headers by using Charles as a reverse-proxy to www.google.com, but I've been able to reproduce using a simple HTTP server that prints out the headers, too.
from spdy.
As I understand it, the main issue is the difference between :host
and Host
. I'll look into why this is happening. It's also odd that the X-Forwarded-For
header is different, but that's not set by my library, so I think that's just an oddity of SpdyLay.
Is there something else I'm missing?
from spdy.
Ah, sorry, I used Chrome because SpdyLay doesn't support regular HTTPS connections (it's a SPDY debugging tool: https://github.com/tatsuhiro-t/spdylay). Trying again with curl works:
$ curl https://localhost:5005/
GET / HTTP/1.1
User-Agent: curl/7.30.0
Accept: */*
X-Forwarded-For: ::1
Accept-Encoding: gzip
Host: www.google.com
My understanding is that, for some reason, the lines that start with ": " aren't actually supposed to be there...?
from spdy.
Those are headers new to SPDY. The :host
, :method
, :path
, :scheme
, and :version
headers must be included in SPDY requests, since they build up the data that would be in an HTTP request line (GET / HTTP/1.1
).
All ok?
from spdy.
Oh, I understand now. So, it's sending SPDY headers to the HTTP backend set up in httputil.NewSingleHostReverseProxy
... Is that expected behavior?
from spdy.
That's the behavior exhibited by httputil.NewSingleHostReverseProxy
. Since it's that code that creates the outward-bound request, it's up to that whether to forward the new headers. However, if I remember correctly, they're still valid HTTP headers, so it shouldn't do any harm to forward them on.
If you don't want to forward the SPDY headers, I suggest writing code similar to the following:
targetURL := url.Parse("http://www.google.com")
reverseProxy := httputil.NewSingleHostReverseProxy(targetURL)
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
for key := range r.Header {
if strings.HasPrefix(key, ":") {
r.Header.Del(key)
}
}
reverseProxy.ServeHTTP(w, r)
})
if err = spdy.ListenAndServeTLS(":5005", "cert.pem", "key.pem", nil); err != nil {
// handle error.
log.Fatal(err)
}
from spdy.
Ah, I see now. Thanks a lot for your time!
from spdy.
Related Issues (20)
- Errors (Received SYN_REPLY with unopened or closed Stream...) during high traffic. HOT 3
- Debug logging in spdy2/3 cannot be turned on
- When a request panics and caught, we get tongs of error_handling.go:18: Error: Received INVALID_STREAM for stream ID HOT 8
- http.Get(api.linode.com) results in 'Unsupported negotiated protocol' error HOT 4
- No Timeout Logic/Deadlock. HOT 4
- Rewrite to be more idiomatic and simpler HOT 1
- Resource leak for SPDY/2 clients HOT 1
- Running spdy with negroni results in no spdy support. HOT 1
- deadlock when client is used by multiple goroutines HOT 1
- Data is not sent if message is near to or larger than window HOT 2
- Leaking streams on close HOT 1
- ServeHTTP panic does not close stream HOT 1
- Hijacking a stream HOT 1
- Push sends :status
- Reconsider spdy/2 HOT 6
- Is this a bug? HOT 2
- Panic to close a running ResponseStream HOT 1
- Crashes and lockups on network error HOT 4
- ResponseStream should NOT wait until the full request has been received HOT 1
- ResponseStream process HEADER frame incorrectly HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spdy.