Commit 3858e319 authored by Matthew Holt's avatar Matthew Holt

A couple pesky env variables to deal with in websockets

parent 37f0a37e
...@@ -51,7 +51,7 @@ func (ws WebSocket) buildEnv(cmd *exec.Cmd) error { ...@@ -51,7 +51,7 @@ func (ws WebSocket) buildEnv(cmd *exec.Cmd) error {
`AUTH_TYPE=`, // Not used `AUTH_TYPE=`, // Not used
`CONTENT_LENGTH=`, // Not used `CONTENT_LENGTH=`, // Not used
`CONTENT_TYPE=`, // Not used `CONTENT_TYPE=`, // Not used
`GATEWAY_INTERFACE=` + gatewayInterface, `GATEWAY_INTERFACE=` + GatewayInterface,
`PATH_INFO=`, // TODO `PATH_INFO=`, // TODO
`PATH_TRANSLATED=`, // TODO `PATH_TRANSLATED=`, // TODO
`QUERY_STRING=` + ws.URL.RawQuery, `QUERY_STRING=` + ws.URL.RawQuery,
...@@ -66,7 +66,7 @@ func (ws WebSocket) buildEnv(cmd *exec.Cmd) error { ...@@ -66,7 +66,7 @@ func (ws WebSocket) buildEnv(cmd *exec.Cmd) error {
`SERVER_NAME=` + serverHost, `SERVER_NAME=` + serverHost,
`SERVER_PORT=` + serverPort, `SERVER_PORT=` + serverPort,
`SERVER_PROTOCOL=` + ws.Proto, `SERVER_PROTOCOL=` + ws.Proto,
`SERVER_SOFTWARE=` + serverSoftware, `SERVER_SOFTWARE=` + ServerSoftware,
} }
// Add each HTTP header to the environment as well // Add each HTTP header to the environment as well
...@@ -80,11 +80,3 @@ func (ws WebSocket) buildEnv(cmd *exec.Cmd) error { ...@@ -80,11 +80,3 @@ func (ws WebSocket) buildEnv(cmd *exec.Cmd) error {
return nil return nil
} }
const (
// See CGI spec, 4.1.4
gatewayInterface = "caddy-CGI/1.1"
// See CGI spec, 4.1.17
serverSoftware = "caddy/0.1.0"
)
...@@ -17,6 +17,7 @@ type ( ...@@ -17,6 +17,7 @@ type (
// websocket middleware generally, like a list of all the // websocket middleware generally, like a list of all the
// websocket endpoints. // websocket endpoints.
WebSockets struct { WebSockets struct {
// Sockets holds all the web socket endpoint configurations
Sockets []WSConfig Sockets []WSConfig
} }
...@@ -47,11 +48,8 @@ func (ws WebSockets) ServeHTTP(w http.ResponseWriter, r *http.Request) { ...@@ -47,11 +48,8 @@ func (ws WebSockets) ServeHTTP(w http.ResponseWriter, r *http.Request) {
func New(c middleware.Controller) (middleware.Middleware, error) { func New(c middleware.Controller) (middleware.Middleware, error) {
var websocks []WSConfig var websocks []WSConfig
var path string
var command string
for c.Next() { for c.Next() {
var val string var val, path, command string
// Path or command; not sure which yet // Path or command; not sure which yet
if !c.NextArg() { if !c.NextArg() {
...@@ -94,9 +92,25 @@ func New(c middleware.Controller) (middleware.Middleware, error) { ...@@ -94,9 +92,25 @@ func New(c middleware.Controller) (middleware.Middleware, error) {
}) })
} }
GatewayInterface = envGatewayInterface
ServerSoftware = envServerSoftware
return func(next http.HandlerFunc) http.HandlerFunc { return func(next http.HandlerFunc) http.HandlerFunc {
// We don't use next because websockets aren't HTTP, // We don't use next because websockets aren't HTTP,
// so we don't invoke other middleware after this. // so we don't invoke other middleware after this.
return WebSockets{Sockets: websocks}.ServeHTTP return WebSockets{Sockets: websocks}.ServeHTTP
}, nil }, nil
} }
var (
// See CGI spec, 4.1.4
GatewayInterface string
// See CGI spec, 4.1.17
ServerSoftware string
)
const (
envGatewayInterface = "caddy-CGI/1.1"
envServerSoftware = "caddy/0.1.0"
)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment