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
c2853ea6
Commit
c2853ea6
authored
Oct 25, 2016
by
Mateusz Gajewski
Committed by
Matt Holt
Oct 25, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use proper Request (#1197)
* Use proper Request * Fixes
parent
561069fd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
42 deletions
+25
-42
.travis.yml
.travis.yml
+1
-2
README.md
README.md
+1
-1
caddyhttp/log/log_test.go
caddyhttp/log/log_test.go
+1
-4
caddyhttp/proxy/proxy_test.go
caddyhttp/proxy/proxy_test.go
+22
-35
No files found.
.travis.yml
View file @
c2853ea6
language
:
go
go
:
-
1.6.3
go
:
-
1.7.3
-
tip
...
...
README.md
View file @
c2853ea6
...
...
@@ -97,7 +97,7 @@ the [CLI documentation](https://caddyserver.com/docs/cli) for details.
## Running from Source
Note: You will need
**[Go 1.
6
](https://golang.org/dl/)**
or newer.
Note: You will need
**[Go 1.
7
](https://golang.org/dl/)**
or newer.
1.
`go get github.com/mholt/caddy/caddy`
2.
`cd`
into your website's directory
...
...
caddyhttp/log/log_test.go
View file @
c2853ea6
...
...
@@ -104,10 +104,7 @@ func TestLogRequestBody(t *testing.T) {
},
}
{
got
.
Reset
()
r
,
err
:=
http
.
NewRequest
(
"POST"
,
"/"
,
bytes
.
NewBufferString
(
c
.
body
))
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
r
:=
httptest
.
NewRequest
(
"POST"
,
"/"
,
bytes
.
NewBufferString
(
c
.
body
))
r
.
Header
.
Set
(
"Content-Type"
,
"application/json"
)
status
,
err
:=
logger
.
ServeHTTP
(
httptest
.
NewRecorder
(),
r
)
if
status
!=
0
{
...
...
caddyhttp/proxy/proxy_test.go
View file @
c2853ea6
...
...
@@ -43,10 +43,7 @@ func TestReverseProxy(t *testing.T) {
}
// create request and response recorder
r
,
err
:=
http
.
NewRequest
(
"GET"
,
"/"
,
nil
)
if
err
!=
nil
{
t
.
Fatalf
(
"Failed to create request: %v"
,
err
)
}
r
:=
httptest
.
NewRequest
(
"GET"
,
"/"
,
nil
)
w
:=
httptest
.
NewRecorder
()
p
.
ServeHTTP
(
w
,
r
)
...
...
@@ -84,10 +81,7 @@ func TestReverseProxyInsecureSkipVerify(t *testing.T) {
}
// create request and response recorder
r
,
err
:=
http
.
NewRequest
(
"GET"
,
"/"
,
nil
)
if
err
!=
nil
{
t
.
Fatalf
(
"Failed to create request: %v"
,
err
)
}
r
:=
httptest
.
NewRequest
(
"GET"
,
"/"
,
nil
)
w
:=
httptest
.
NewRecorder
()
p
.
ServeHTTP
(
w
,
r
)
...
...
@@ -114,10 +108,8 @@ func TestWebSocketReverseProxyNonHijackerPanic(t *testing.T) {
p
:=
newWebSocketTestProxy
(
wsNop
.
URL
)
// Create client request
r
,
err
:=
http
.
NewRequest
(
"GET"
,
"/"
,
nil
)
if
err
!=
nil
{
t
.
Fatalf
(
"Failed to create request: %v"
,
err
)
}
r
:=
httptest
.
NewRequest
(
"GET"
,
"/"
,
nil
)
r
.
Header
=
http
.
Header
{
"Connection"
:
{
"Upgrade"
},
"Upgrade"
:
{
"websocket"
},
...
...
@@ -141,10 +133,8 @@ func TestWebSocketReverseProxyServeHTTPHandler(t *testing.T) {
p
:=
newWebSocketTestProxy
(
wsNop
.
URL
)
// Create client request
r
,
err
:=
http
.
NewRequest
(
"GET"
,
"/"
,
nil
)
if
err
!=
nil
{
t
.
Fatalf
(
"Failed to create request: %v"
,
err
)
}
r
:=
httptest
.
NewRequest
(
"GET"
,
"/"
,
nil
)
r
.
Header
=
http
.
Header
{
"Connection"
:
{
"Upgrade"
},
"Upgrade"
:
{
"websocket"
},
...
...
@@ -195,6 +185,7 @@ func TestWebSocketReverseProxyFromWSClient(t *testing.T) {
// Set up WebSocket client
url
:=
strings
.
Replace
(
echoProxy
.
URL
,
"http://"
,
"ws://"
,
1
)
ws
,
err
:=
websocket
.
Dial
(
url
,
""
,
echoProxy
.
URL
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
@@ -202,11 +193,18 @@ func TestWebSocketReverseProxyFromWSClient(t *testing.T) {
// Send test message
trialMsg
:=
"Is it working?"
websocket
.
Message
.
Send
(
ws
,
trialMsg
)
if
sendErr
:=
websocket
.
Message
.
Send
(
ws
,
trialMsg
);
sendErr
!=
nil
{
t
.
Fatal
(
sendErr
)
}
// It should be echoed back to us
var
actualMsg
string
websocket
.
Message
.
Receive
(
ws
,
&
actualMsg
)
if
rcvErr
:=
websocket
.
Message
.
Receive
(
ws
,
&
actualMsg
);
rcvErr
!=
nil
{
t
.
Fatal
(
rcvErr
)
}
if
actualMsg
!=
trialMsg
{
t
.
Errorf
(
"Expected '%s' but got '%s' instead"
,
trialMsg
,
actualMsg
)
}
...
...
@@ -419,10 +417,7 @@ func TestUpstreamHeadersUpdate(t *testing.T) {
}
// create request and response recorder
r
,
err
:=
http
.
NewRequest
(
"GET"
,
"/"
,
nil
)
if
err
!=
nil
{
t
.
Fatalf
(
"Failed to create request: %v"
,
err
)
}
r
:=
httptest
.
NewRequest
(
"GET"
,
"/"
,
nil
)
w
:=
httptest
.
NewRecorder
()
const
expectHost
=
"example.com"
...
...
@@ -499,10 +494,7 @@ func TestDownstreamHeadersUpdate(t *testing.T) {
}
// create request and response recorder
r
,
err
:=
http
.
NewRequest
(
"GET"
,
"/"
,
nil
)
if
err
!=
nil
{
t
.
Fatalf
(
"Failed to create request: %v"
,
err
)
}
r
:=
httptest
.
NewRequest
(
"GET"
,
"/"
,
nil
)
w
:=
httptest
.
NewRecorder
()
// set a predefined skip header
w
.
Header
()
.
Set
(
"Content-Type"
,
"text/css"
)
...
...
@@ -627,8 +619,9 @@ func TestMultiReverseProxyFromClient(t *testing.T) {
// Create client request
reqURL
:=
proxy
.
URL
+
tt
.
url
req
,
err
:=
http
.
NewRequest
(
"GET"
,
reqURL
,
nil
)
if
err
!=
nil
{
t
.
Fatalf
(
"Failed to
creat
e request: %v"
,
err
)
t
.
Fatalf
(
"Failed to
mak
e request: %v"
,
err
)
}
resp
,
err
:=
http
.
DefaultClient
.
Do
(
req
)
...
...
@@ -661,12 +654,9 @@ func TestHostSimpleProxyNoHeaderForward(t *testing.T) {
Upstreams
:
[]
Upstream
{
newFakeUpstream
(
backend
.
URL
,
false
)},
}
r
,
err
:=
http
.
NewRequest
(
"GET"
,
"/"
,
nil
)
r
:=
httptest
.
NewRequest
(
"GET"
,
"/"
,
nil
)
r
.
Host
=
"test.com"
if
err
!=
nil
{
t
.
Fatalf
(
"Failed to create request: %v"
,
err
)
}
w
:=
httptest
.
NewRecorder
()
p
.
ServeHTTP
(
w
,
r
)
...
...
@@ -698,12 +688,9 @@ func TestHostHeaderReplacedUsingForward(t *testing.T) {
Upstreams
:
[]
Upstream
{
upstream
},
}
r
,
err
:=
http
.
NewRequest
(
"GET"
,
"/"
,
nil
)
r
:=
httptest
.
NewRequest
(
"GET"
,
"/"
,
nil
)
r
.
Host
=
"test.com"
if
err
!=
nil
{
t
.
Fatalf
(
"Failed to create request: %v"
,
err
)
}
w
:=
httptest
.
NewRecorder
()
p
.
ServeHTTP
(
w
,
r
)
...
...
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