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
600ee9a8
Commit
600ee9a8
authored
Jan 31, 2016
by
Matthew Holt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fastcgi: Accept any other methods as a POST-style request
parent
c5983e30
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
37 deletions
+11
-37
middleware/fastcgi/fastcgi.go
middleware/fastcgi/fastcgi.go
+1
-9
middleware/fastcgi/fcgiclient.go
middleware/fastcgi/fcgiclient.go
+9
-27
middleware/fastcgi/fcgiclient_test.go
middleware/fastcgi/fcgiclient_test.go
+1
-1
No files found.
middleware/fastcgi/fastcgi.go
View file @
600ee9a8
...
...
@@ -85,16 +85,8 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error)
resp
,
err
=
fcgi
.
Get
(
env
)
case
"OPTIONS"
:
resp
,
err
=
fcgi
.
Options
(
env
)
case
"POST"
:
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
:
re
turn
http
.
StatusMethodNotAllowed
,
nil
re
sp
,
err
=
fcgi
.
Post
(
env
,
r
.
Method
,
r
.
Header
.
Get
(
"Content-Type"
),
r
.
Body
,
contentLength
)
}
if
resp
.
Body
!=
nil
{
...
...
middleware/fastcgi/fcgiclient.go
View file @
600ee9a8
...
...
@@ -484,11 +484,17 @@ func (c *FCGIClient) Options(p map[string]string) (resp *http.Response, err erro
// Post issues a POST request to the fcgi responder. with request body
// in the format that bodyType specified
func
(
c
*
FCGIClient
)
Post
(
p
map
[
string
]
string
,
bodyType
string
,
body
io
.
Reader
,
l
int
)
(
resp
*
http
.
Response
,
err
error
)
{
func
(
c
*
FCGIClient
)
Post
(
p
map
[
string
]
string
,
method
string
,
bodyType
string
,
body
io
.
Reader
,
l
int
)
(
resp
*
http
.
Response
,
err
error
)
{
if
p
==
nil
{
p
=
make
(
map
[
string
]
string
)
}
p
[
"REQUEST_METHOD"
]
=
strings
.
ToUpper
(
method
)
if
len
(
p
[
"REQUEST_METHOD"
])
==
0
||
p
[
"REQUEST_METHOD"
]
==
"GET"
{
p
[
"REQUEST_METHOD"
]
=
"POST"
}
p
[
"CONTENT_LENGTH"
]
=
strconv
.
Itoa
(
l
)
if
len
(
bodyType
)
>
0
{
p
[
"CONTENT_TYPE"
]
=
bodyType
...
...
@@ -499,35 +505,11 @@ func (c *FCGIClient) Post(p map[string]string, bodyType string, body io.Reader,
return
c
.
Request
(
p
,
body
)
}
// Put issues a PUT request to the fcgi responder.
func
(
c
*
FCGIClient
)
Put
(
p
map
[
string
]
string
,
bodyType
string
,
body
io
.
Reader
,
l
int
)
(
resp
*
http
.
Response
,
err
error
)
{
p
[
"REQUEST_METHOD"
]
=
"PUT"
return
c
.
Post
(
p
,
bodyType
,
body
,
l
)
}
// Patch issues a PATCH request to the fcgi responder.
func
(
c
*
FCGIClient
)
Patch
(
p
map
[
string
]
string
,
bodyType
string
,
body
io
.
Reader
,
l
int
)
(
resp
*
http
.
Response
,
err
error
)
{
p
[
"REQUEST_METHOD"
]
=
"PATCH"
return
c
.
Post
(
p
,
bodyType
,
body
,
l
)
}
// Delete issues a DELETE request to the fcgi responder.
func
(
c
*
FCGIClient
)
Delete
(
p
map
[
string
]
string
,
bodyType
string
,
body
io
.
Reader
,
l
int
)
(
resp
*
http
.
Response
,
err
error
)
{
p
[
"REQUEST_METHOD"
]
=
"DELETE"
return
c
.
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
(
c
*
FCGIClient
)
PostForm
(
p
map
[
string
]
string
,
data
url
.
Values
)
(
resp
*
http
.
Response
,
err
error
)
{
body
:=
bytes
.
NewReader
([]
byte
(
data
.
Encode
()))
return
c
.
Post
(
p
,
"application/x-www-form-urlencoded"
,
body
,
body
.
Len
())
return
c
.
Post
(
p
,
"
POST"
,
"
application/x-www-form-urlencoded"
,
body
,
body
.
Len
())
}
// PostFile issues a POST to the fcgi responder in multipart(RFC 2046) standard,
...
...
@@ -566,7 +548,7 @@ func (c *FCGIClient) PostFile(p map[string]string, data url.Values, file map[str
return
}
return
c
.
Post
(
p
,
bodyType
,
buf
,
buf
.
Len
())
return
c
.
Post
(
p
,
"POST"
,
bodyType
,
buf
,
buf
.
Len
())
}
// Checks whether chunked is part of the encodings stack
...
...
middleware/fastcgi/fcgiclient_test.go
View file @
600ee9a8
...
...
@@ -119,7 +119,7 @@ func sendFcgi(reqType int, fcgiParams map[string]string, data []byte, posts map[
if
len
(
data
)
>
0
{
length
=
len
(
data
)
rd
:=
bytes
.
NewReader
(
data
)
resp
,
err
=
fcgi
.
Post
(
fcgiParams
,
""
,
rd
,
rd
.
Len
())
resp
,
err
=
fcgi
.
Post
(
fcgiParams
,
""
,
""
,
rd
,
rd
.
Len
())
}
else
if
len
(
posts
)
>
0
{
values
:=
url
.
Values
{}
for
k
,
v
:=
range
posts
{
...
...
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