Ticket #30998: 0001-Return-HTTP-1.1-since-it-s-required-by-the-RFC.patch

File 0001-Return-HTTP-1.1-since-it-s-required-by-the-RFC.patch, 1.6 KB (added by arlolra, 6 months ago)
  • websocket/websocket.go

    From 81ebc861e58fa6c27ca94694733a8ba2a6dcc4d1 Mon Sep 17 00:00:00 2001
    From: Arlo Breault <arlolra@gmail.com>
    Date: Thu, 27 Jun 2019 12:49:49 -0400
    Subject: [PATCH] Return HTTP/1.1 since it's required by the RFC
    
    It appears at least Safari has introduced stricter validation around
    this.
    ---
     websocket/websocket.go | 4 ++--
     1 file changed, 2 insertions(+), 2 deletions(-)
    
    diff --git a/websocket/websocket.go b/websocket/websocket.go
    index 73b1ce7..ea15218 100644
    a b func sha1Hash(data string) []byte { 
    310310
    311311func httpError(w http.ResponseWriter, bufrw *bufio.ReadWriter, code int) {
    312312        w.Header().Set("Connection", "close")
    313         bufrw.WriteString(fmt.Sprintf("HTTP/1.0 %d %s\r\n", code, http.StatusText(code)))
     313        bufrw.WriteString(fmt.Sprintf("HTTP/1.1 %d %s\r\n", code, http.StatusText(code)))
    314314        w.Header().Write(bufrw)
    315315        bufrw.WriteString("\r\n")
    316316        bufrw.Flush()
    func (handler *HTTPHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) 
    395395        // See RFC 6455 section 4.2.2, item 5 for these steps.
    396396
    397397        // 1. A Status-Line with a 101 response code as per RFC 2616.
    398         bufrw.WriteString(fmt.Sprintf("HTTP/1.0 %d %s\r\n", http.StatusSwitchingProtocols, http.StatusText(http.StatusSwitchingProtocols)))
     398        bufrw.WriteString(fmt.Sprintf("HTTP/1.1 %d %s\r\n", http.StatusSwitchingProtocols, http.StatusText(http.StatusSwitchingProtocols)))
    399399        // 2. An |Upgrade| header field with value "websocket" as per RFC 2616.
    400400        w.Header().Set("Upgrade", "websocket")
    401401        // 3. A |Connection| header field with value "Upgrade".