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 {
`AUTH_TYPE=`, // Not used
`CONTENT_LENGTH=`, // Not used
`CONTENT_TYPE=`, // Not used
`GATEWAY_INTERFACE=` + gatewayInterface,
`GATEWAY_INTERFACE=` + GatewayInterface,
`PATH_INFO=`, // TODO
`PATH_TRANSLATED=`, // TODO
`QUERY_STRING=` + ws.URL.RawQuery,
......@@ -66,7 +66,7 @@ func (ws WebSocket) buildEnv(cmd *exec.Cmd) error {
`SERVER_NAME=` + serverHost,
`SERVER_PORT=` + serverPort,
`SERVER_PROTOCOL=` + ws.Proto,
`SERVER_SOFTWARE=` + serverSoftware,
`SERVER_SOFTWARE=` + ServerSoftware,
}
// Add each HTTP header to the environment as well
......@@ -80,11 +80,3 @@ func (ws WebSocket) buildEnv(cmd *exec.Cmd) error {
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 (
// websocket middleware generally, like a list of all the
// websocket endpoints.
WebSockets struct {
// Sockets holds all the web socket endpoint configurations
Sockets []WSConfig
}
......@@ -47,11 +48,8 @@ func (ws WebSockets) ServeHTTP(w http.ResponseWriter, r *http.Request) {
func New(c middleware.Controller) (middleware.Middleware, error) {
var websocks []WSConfig
var path string
var command string
for c.Next() {
var val string
var val, path, command string
// Path or command; not sure which yet
if !c.NextArg() {
......@@ -94,9 +92,25 @@ func New(c middleware.Controller) (middleware.Middleware, error) {
})
}
GatewayInterface = envGatewayInterface
ServerSoftware = envServerSoftware
return func(next http.HandlerFunc) http.HandlerFunc {
// We don't use next because websockets aren't HTTP,
// so we don't invoke other middleware after this.
return WebSockets{Sockets: websocks}.ServeHTTP
}, 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