branch: externals/websocket
commit 8cae91f73815bff749b04fb61f332107f0d0ed7b
Author: Joe Corneli <[email protected]>
Commit: Joe Corneli <[email protected]>

    Fix missing leading slash in WebSocket request path
    
    When the URL has no path component (e.g., wss://host:port?query=...),
    url-filename returns "?query=..." without a leading slash.
    
    This produces an invalid HTTP request line:
      GET ?query=... HTTP/1.1
    
    Instead of the correct:
      GET /?query=... HTTP/1.1
    
    Servers like nginx correctly reject this as 400 Bad Request.
    
    The fix ensures the path always starts with "/" by checking
    string-prefix-p before using url-filename's result.
    
    Fixes #66 (TLSv1.3 connection issues with nginx)
---
 websocket.el | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/websocket.el b/websocket.el
index a5c0591d4f..9dc59a9d1c 100644
--- a/websocket.el
+++ b/websocket.el
@@ -735,7 +735,10 @@ to the websocket protocol.
       (process-send-string conn
                            (format "GET %s HTTP/1.1\r\n%s"
                                    (let ((path (url-filename url-struct)))
-                                     (if (> (length path) 0) path "/"))
+                                     (cond
+                                      ((= (length path) 0) "/")
+                                      ((string-prefix-p "/" path) path)
+                                      (t (concat "/" path))))
                                    (websocket-create-headers
                                     url key protocols extensions 
custom-header-alist))))))
 

Reply via email to