Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caddy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
caddy
Commits
3858e319
Commit
3858e319
authored
Mar 03, 2015
by
Matthew Holt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
A couple pesky env variables to deal with in websockets
parent
37f0a37e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
14 deletions
+20
-14
middleware/websockets/websocket.go
middleware/websockets/websocket.go
+2
-10
middleware/websockets/websockets.go
middleware/websockets/websockets.go
+18
-4
No files found.
middleware/websockets/websocket.go
View file @
3858e319
...
@@ -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=`
+
g
atewayInterface
,
`GATEWAY_INTERFACE=`
+
G
atewayInterface
,
`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=`
+
s
erverSoftware
,
`SERVER_SOFTWARE=`
+
S
erverSoftware
,
}
}
// 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"
)
middleware/websockets/websockets.go
View file @
3858e319
...
@@ -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"
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment