mirror of
				https://github.com/caddyserver/caddy.git
				synced 2025-11-04 10:12:29 +08:00 
			
		
		
		
	reverseproxy: Ignore RFC 1521 params in Content-Type header (#3758)
Without this change, a Content-Type header like "text/event-stream;charset=utf-8" would not trigger the immediate flushing. Fixes #3765
This commit is contained in:
		@ -21,6 +21,7 @@ package reverseproxy
 | 
				
			|||||||
import (
 | 
					import (
 | 
				
			||||||
	"context"
 | 
						"context"
 | 
				
			||||||
	"io"
 | 
						"io"
 | 
				
			||||||
 | 
						"mime"
 | 
				
			||||||
	"net/http"
 | 
						"net/http"
 | 
				
			||||||
	"sync"
 | 
						"sync"
 | 
				
			||||||
	"time"
 | 
						"time"
 | 
				
			||||||
@ -88,11 +89,12 @@ func (h Handler) handleUpgradeResponse(rw http.ResponseWriter, req *http.Request
 | 
				
			|||||||
// flushInterval returns the p.FlushInterval value, conditionally
 | 
					// flushInterval returns the p.FlushInterval value, conditionally
 | 
				
			||||||
// overriding its value for a specific request/response.
 | 
					// overriding its value for a specific request/response.
 | 
				
			||||||
func (h Handler) flushInterval(req *http.Request, res *http.Response) time.Duration {
 | 
					func (h Handler) flushInterval(req *http.Request, res *http.Response) time.Duration {
 | 
				
			||||||
	resCT := res.Header.Get("Content-Type")
 | 
						resCTHeader := res.Header.Get("Content-Type")
 | 
				
			||||||
 | 
						resCT, _, err := mime.ParseMediaType(resCTHeader)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// For Server-Sent Events responses, flush immediately.
 | 
						// For Server-Sent Events responses, flush immediately.
 | 
				
			||||||
	// The MIME type is defined in https://www.w3.org/TR/eventsource/#text-event-stream
 | 
						// The MIME type is defined in https://www.w3.org/TR/eventsource/#text-event-stream
 | 
				
			||||||
	if resCT == "text/event-stream" {
 | 
						if err == nil && resCT == "text/event-stream" {
 | 
				
			||||||
		return -1 // negative means immediately
 | 
							return -1 // negative means immediately
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user