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
bb85a845
Commit
bb85a845
authored
Sep 28, 2015
by
Mathias Beke
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'upstream/master'
Conflicts: middleware/fastcgi/fastcgi.go
parents
8baead61
be6fc353
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
7 deletions
+22
-7
middleware/fastcgi/fastcgi.go
middleware/fastcgi/fastcgi.go
+12
-4
middleware/fastcgi/fcgiclient.go
middleware/fastcgi/fcgiclient.go
+2
-2
middleware/rewrite/rewrite.go
middleware/rewrite/rewrite.go
+7
-0
server/server.go
server/server.go
+1
-1
No files found.
middleware/fastcgi/fastcgi.go
View file @
bb85a845
...
...
@@ -167,9 +167,17 @@ func (h Handler) buildEnv(r *http.Request, rule Rule, fpath string) (map[string]
}
// Strip PATH_INFO from SCRIPT_NAME
indexPathInfo
:=
strings
.
LastIndex
(
scriptName
,
pathInfo
)
if
indexPathInfo
!=
-
1
{
scriptName
=
scriptName
[
:
indexPathInfo
]
scriptName
=
strings
.
TrimSuffix
(
scriptName
,
pathInfo
)
// Get the request URI. The request URI might be as it came in over the wire,
// or it might have been rewritten internally by the rewrite middleware (see issue #256).
// If it was rewritten, there will be a header indicating the original URL,
// which is needed to get the correct RequestURI value for PHP apps.
const
internalRewriteFieldName
=
"Caddy-Rewrite-Original-URI"
reqURI
:=
r
.
URL
.
RequestURI
()
if
origURI
:=
r
.
Header
.
Get
(
internalRewriteFieldName
);
origURI
!=
""
{
reqURI
=
origURI
r
.
Header
.
Del
(
internalRewriteFieldName
)
}
// Some variables are unused but cleared explicitly to prevent
...
...
@@ -198,7 +206,7 @@ func (h Handler) buildEnv(r *http.Request, rule Rule, fpath string) (map[string]
"DOCUMENT_ROOT"
:
h
.
AbsRoot
,
"DOCUMENT_URI"
:
docURI
,
"HTTP_HOST"
:
r
.
Host
,
// added here, since not always part of headers
"REQUEST_URI"
:
r
.
URL
.
RequestURI
()
,
"REQUEST_URI"
:
r
eqURI
,
"SCRIPT_FILENAME"
:
scriptFilename
,
"SCRIPT_NAME"
:
scriptName
,
}
...
...
middleware/fastcgi/fcgiclient.go
View file @
bb85a845
...
...
@@ -381,9 +381,9 @@ func (c *FCGIClient) Request(p map[string]string, req io.Reader) (resp *http.Res
return
}
if
len
(
statusParts
)
>
1
{
resp
.
Status
=
statusParts
[
1
]
resp
.
Status
=
statusParts
[
1
]
}
}
else
{
resp
.
StatusCode
=
http
.
StatusOK
}
...
...
middleware/rewrite/rewrite.go
View file @
bb85a845
...
...
@@ -49,6 +49,9 @@ func NewSimpleRule(from, to string) SimpleRule {
// Rewrite rewrites the internal location of the current request.
func
(
s
SimpleRule
)
Rewrite
(
r
*
http
.
Request
)
bool
{
if
s
.
From
==
r
.
URL
.
Path
{
// take note of this rewrite for internal use by fastcgi
// all we need is the URI, not full URL
r
.
Header
.
Set
(
"Caddy-Rewrite-Original-URI"
,
r
.
URL
.
RequestURI
())
r
.
URL
.
Path
=
s
.
To
return
true
}
...
...
@@ -129,6 +132,10 @@ func (r *RegexpRule) Rewrite(req *http.Request) bool {
return
false
}
// take note of this rewrite for internal use by fastcgi
// all we need is the URI, not full URL
req
.
Header
.
Set
(
"Caddy-Rewrite-Original-URI"
,
req
.
URL
.
RequestURI
())
// perform rewrite
req
.
URL
.
Path
=
url
.
Path
if
url
.
RawQuery
!=
""
{
...
...
server/server.go
View file @
bb85a845
...
...
@@ -14,7 +14,7 @@ import (
"os"
"os/signal"
"g
ithub.com/bradfitz
/http2"
"g
olang.org/x/net
/http2"
)
// Server represents an instance of a server, which serves
...
...
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