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
Łukasz Nowak
caddy
Commits
225d5977
Commit
225d5977
authored
May 03, 2015
by
Abiola Ibrahim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fastcgi: allow more request types.
parent
747d59b8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
3 deletions
+43
-3
middleware/fastcgi/fastcgi.go
middleware/fastcgi/fastcgi.go
+10
-3
middleware/fastcgi/fcgiclient.go
middleware/fastcgi/fcgiclient.go
+33
-0
No files found.
middleware/fastcgi/fastcgi.go
View file @
225d5977
...
...
@@ -85,14 +85,21 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error)
return
http
.
StatusBadGateway
,
err
}
// TODO: Allow more methods (requires refactoring fcgiclient first...)
var
resp
*
http
.
Response
contentLength
,
_
:=
strconv
.
Atoi
(
r
.
Header
.
Get
(
"Content-Length"
))
switch
r
.
Method
{
case
"HEAD"
:
resp
,
err
=
fcgi
.
Head
(
env
)
case
"GET"
:
resp
,
err
=
fcgi
.
Get
(
env
)
case
"POST"
:
l
,
_
:=
strconv
.
Atoi
(
r
.
Header
.
Get
(
"Content-Length"
))
resp
,
err
=
fcgi
.
Post
(
env
,
r
.
Header
.
Get
(
"Content-Type"
),
r
.
Body
,
l
)
resp
,
err
=
fcgi
.
Post
(
env
,
r
.
Header
.
Get
(
"Content-Type"
),
r
.
Body
,
contentLength
)
case
"PUT"
:
resp
,
err
=
fcgi
.
Put
(
env
,
r
.
Header
.
Get
(
"Content-Type"
),
r
.
Body
,
contentLength
)
case
"PATCH"
:
resp
,
err
=
fcgi
.
Patch
(
env
,
r
.
Header
.
Get
(
"Content-Type"
),
r
.
Body
,
contentLength
)
case
"DELETE"
:
resp
,
err
=
fcgi
.
Delete
(
env
,
r
.
Header
.
Get
(
"Content-Type"
),
r
.
Body
,
contentLength
)
default
:
return
http
.
StatusMethodNotAllowed
,
nil
}
...
...
middleware/fastcgi/fcgiclient.go
View file @
225d5977
...
...
@@ -407,6 +407,15 @@ func (this *FCGIClient) Get(p map[string]string) (resp *http.Response, err error
return
this
.
Request
(
p
,
nil
)
}
// Head issues a HEAD request to the fcgi responder.
func
(
this
*
FCGIClient
)
Head
(
p
map
[
string
]
string
)
(
resp
*
http
.
Response
,
err
error
)
{
p
[
"REQUEST_METHOD"
]
=
"HEAD"
p
[
"CONTENT_LENGTH"
]
=
"0"
return
this
.
Request
(
p
,
nil
)
}
// Get issues a Post request to the fcgi responder. with request body
// in the format that bodyType specified
func
(
this
*
FCGIClient
)
Post
(
p
map
[
string
]
string
,
bodyType
string
,
body
io
.
Reader
,
l
int
)
(
resp
*
http
.
Response
,
err
error
)
{
...
...
@@ -424,6 +433,30 @@ func (this *FCGIClient) Post(p map[string]string, bodyType string, body io.Reade
return
this
.
Request
(
p
,
body
)
}
// Put issues a PUT request to the fcgi responder.
func
(
this
*
FCGIClient
)
Put
(
p
map
[
string
]
string
,
bodyType
string
,
body
io
.
Reader
,
l
int
)
(
resp
*
http
.
Response
,
err
error
)
{
p
[
"REQUEST_METHOD"
]
=
"PUT"
return
this
.
Post
(
p
,
bodyType
,
body
,
l
)
}
// Patch issues a PATCH request to the fcgi responder.
func
(
this
*
FCGIClient
)
Patch
(
p
map
[
string
]
string
,
bodyType
string
,
body
io
.
Reader
,
l
int
)
(
resp
*
http
.
Response
,
err
error
)
{
p
[
"REQUEST_METHOD"
]
=
"PATCH"
return
this
.
Post
(
p
,
bodyType
,
body
,
l
)
}
// Delete issues a DELETE request to the fcgi responder.
func
(
this
*
FCGIClient
)
Delete
(
p
map
[
string
]
string
,
bodyType
string
,
body
io
.
Reader
,
l
int
)
(
resp
*
http
.
Response
,
err
error
)
{
p
[
"REQUEST_METHOD"
]
=
"DELETE"
return
this
.
Post
(
p
,
bodyType
,
body
,
l
)
}
// PostForm issues a POST to the fcgi responder, with form
// as a string key to a list values (url.Values)
func
(
this
*
FCGIClient
)
PostForm
(
p
map
[
string
]
string
,
data
url
.
Values
)
(
resp
*
http
.
Response
,
err
error
)
{
...
...
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