1234567891011121314151617181920212223242526272829303132333435363738 |
- package dpcore
- import (
- "mime"
- "net/http"
- "time"
- )
- func (p *ReverseProxy) getFlushInterval(req *http.Request, res *http.Response) time.Duration {
- contentType := req.Header.Get("Content-Type")
- if actualContentType, _, _ := mime.ParseMediaType(contentType); actualContentType == "text/event-stream" {
- return -1
- }
- if req.ContentLength == -1 || p.isBidirectionalStream(req, res) {
- return -1
- }
-
- return p.FlushInterval
- }
- func (p *ReverseProxy) isBidirectionalStream(req *http.Request, res *http.Response) bool {
-
-
-
-
-
- ae := req.Header.Get("Accept-Encoding")
- return req.ProtoMajor == 2 &&
- res.ProtoMajor == 2 &&
- res.ContentLength == -1 &&
- (ae == "identity" || ae == "")
- }
|