Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nghttp2
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
nghttp2
Commits
d48d399f
Commit
d48d399f
authored
Jun 13, 2016
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Allow query in API endpoint
parent
34468ecc
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
119 additions
and
3 deletions
+119
-3
integration-tests/nghttpx_http1_test.go
integration-tests/nghttpx_http1_test.go
+37
-0
integration-tests/nghttpx_http2_test.go
integration-tests/nghttpx_http2_test.go
+37
-0
integration-tests/nghttpx_spdy_test.go
integration-tests/nghttpx_spdy_test.go
+37
-0
integration-tests/server_tester.go
integration-tests/server_tester.go
+3
-2
src/shrpx_api_downstream_connection.cc
src/shrpx_api_downstream_connection.cc
+5
-1
No files found.
integration-tests/nghttpx_http1_test.go
View file @
d48d399f
...
@@ -832,6 +832,43 @@ backend=127.0.0.1,3011
...
@@ -832,6 +832,43 @@ backend=127.0.0.1,3011
}
}
}
}
// TestH1APIBackendReplaceQuery exercise backendconfig API endpoint
// routine with query.
func
TestH1APIBackendReplaceQuery
(
t
*
testing
.
T
)
{
st
:=
newServerTesterConnectPort
([]
string
{
"-f127.0.0.1,3010;api;no-tls"
},
t
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
t
.
Fatalf
(
"request should not be forwarded"
)
},
3010
)
defer
st
.
Close
()
res
,
err
:=
st
.
http1
(
requestParam
{
name
:
"TestH1APIBackendReplaceQuery"
,
path
:
"/api/v1beta1/backendconfig?foo=bar"
,
method
:
"PUT"
,
body
:
[]
byte
(
`# comment
backend=127.0.0.1,3011
`
),
})
if
err
!=
nil
{
t
.
Fatalf
(
"Error st.http1() = %v"
,
err
)
}
if
got
,
want
:=
res
.
status
,
200
;
got
!=
want
{
t
.
Errorf
(
"res.status: %v; want %v"
,
got
,
want
)
}
var
apiResp
APIResponse
err
=
json
.
Unmarshal
(
res
.
body
,
&
apiResp
)
if
err
!=
nil
{
t
.
Fatalf
(
"Error unmarshaling API response: %v"
,
err
)
}
if
got
,
want
:=
apiResp
.
Status
,
"Success"
;
got
!=
want
{
t
.
Errorf
(
"apiResp.Status: %v; want %v"
,
got
,
want
)
}
if
got
,
want
:=
apiResp
.
Code
,
200
;
got
!=
want
{
t
.
Errorf
(
"apiResp.Status: %v; want %v"
,
got
,
want
)
}
}
// TestH1APIBackendReplaceBadMethod exercise backendconfig API
// TestH1APIBackendReplaceBadMethod exercise backendconfig API
// endpoint routine with bad method.
// endpoint routine with bad method.
func
TestH1APIBackendReplaceBadMethod
(
t
*
testing
.
T
)
{
func
TestH1APIBackendReplaceBadMethod
(
t
*
testing
.
T
)
{
...
...
integration-tests/nghttpx_http2_test.go
View file @
d48d399f
...
@@ -1882,6 +1882,43 @@ backend=127.0.0.1,3011
...
@@ -1882,6 +1882,43 @@ backend=127.0.0.1,3011
}
}
}
}
// TestH2APIBackendReplaceQuery exercise backendconfig API endpoint
// routine with query.
func
TestH2APIBackendReplaceQuery
(
t
*
testing
.
T
)
{
st
:=
newServerTesterConnectPort
([]
string
{
"-f127.0.0.1,3010;api;no-tls"
},
t
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
t
.
Fatalf
(
"request should not be forwarded"
)
},
3010
)
defer
st
.
Close
()
res
,
err
:=
st
.
http2
(
requestParam
{
name
:
"TestH2APIBackendReplaceQuery"
,
path
:
"/api/v1beta1/backendconfig?foo=bar"
,
method
:
"PUT"
,
body
:
[]
byte
(
`# comment
backend=127.0.0.1,3011
`
),
})
if
err
!=
nil
{
t
.
Fatalf
(
"Error st.http2() = %v"
,
err
)
}
if
got
,
want
:=
res
.
status
,
200
;
got
!=
want
{
t
.
Errorf
(
"res.status: %v; want %v"
,
got
,
want
)
}
var
apiResp
APIResponse
err
=
json
.
Unmarshal
(
res
.
body
,
&
apiResp
)
if
err
!=
nil
{
t
.
Fatalf
(
"Error unmarshaling API response: %v"
,
err
)
}
if
got
,
want
:=
apiResp
.
Status
,
"Success"
;
got
!=
want
{
t
.
Errorf
(
"apiResp.Status: %v; want %v"
,
got
,
want
)
}
if
got
,
want
:=
apiResp
.
Code
,
200
;
got
!=
want
{
t
.
Errorf
(
"apiResp.Status: %v; want %v"
,
got
,
want
)
}
}
// TestH2APIBackendReplaceBadMethod exercise backendconfig API
// TestH2APIBackendReplaceBadMethod exercise backendconfig API
// endpoint routine with bad method.
// endpoint routine with bad method.
func
TestH2APIBackendReplaceBadMethod
(
t
*
testing
.
T
)
{
func
TestH2APIBackendReplaceBadMethod
(
t
*
testing
.
T
)
{
...
...
integration-tests/nghttpx_spdy_test.go
View file @
d48d399f
...
@@ -513,6 +513,43 @@ backend=127.0.0.1,3011
...
@@ -513,6 +513,43 @@ backend=127.0.0.1,3011
}
}
}
}
// TestS3APIBackendReplaceQuery exercise backendconfig API endpoint
// routine with query.
func
TestS3APIBackendReplaceQuery
(
t
*
testing
.
T
)
{
st
:=
newServerTesterTLSConnectPort
([]
string
{
"--npn-list=spdy/3.1"
,
"-f127.0.0.1,3010;api"
},
t
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
t
.
Fatalf
(
"request should not be forwarded"
)
},
3010
)
defer
st
.
Close
()
res
,
err
:=
st
.
spdy
(
requestParam
{
name
:
"TestS3APIBackendReplaceQuery"
,
path
:
"/api/v1beta1/backendconfig?foo=bar"
,
method
:
"PUT"
,
body
:
[]
byte
(
`# comment
backend=127.0.0.1,3011
`
),
})
if
err
!=
nil
{
t
.
Fatalf
(
"Error st.spdy() = %v"
,
err
)
}
if
got
,
want
:=
res
.
status
,
200
;
got
!=
want
{
t
.
Errorf
(
"res.status: %v; want %v"
,
got
,
want
)
}
var
apiResp
APIResponse
err
=
json
.
Unmarshal
(
res
.
body
,
&
apiResp
)
if
err
!=
nil
{
t
.
Fatalf
(
"Error unmarshaling API response: %v"
,
err
)
}
if
got
,
want
:=
apiResp
.
Status
,
"Success"
;
got
!=
want
{
t
.
Errorf
(
"apiResp.Status: %v; want %v"
,
got
,
want
)
}
if
got
,
want
:=
apiResp
.
Code
,
200
;
got
!=
want
{
t
.
Errorf
(
"apiResp.Status: %v; want %v"
,
got
,
want
)
}
}
// TestS3APIBackendReplaceBadMethod exercise backendconfig API
// TestS3APIBackendReplaceBadMethod exercise backendconfig API
// endpoint routine with bad method.
// endpoint routine with bad method.
func
TestS3APIBackendReplaceBadMethod
(
t
*
testing
.
T
)
{
func
TestS3APIBackendReplaceBadMethod
(
t
*
testing
.
T
)
{
...
...
integration-tests/server_tester.go
View file @
d48d399f
...
@@ -379,8 +379,9 @@ func (st *serverTester) http1(rp requestParam) (*serverResponse, error) {
...
@@ -379,8 +379,9 @@ func (st *serverTester) http1(rp requestParam) (*serverResponse, error) {
if
err
!=
nil
{
if
err
!=
nil
{
st
.
t
.
Fatalf
(
"Error parsing URL from st.url %v: %v"
,
st
.
url
,
err
)
st
.
t
.
Fatalf
(
"Error parsing URL from st.url %v: %v"
,
st
.
url
,
err
)
}
}
u
.
Path
=
rp
.
path
u
.
Path
=
""
reqURL
=
u
.
String
()
u
.
RawQuery
=
""
reqURL
=
u
.
String
()
+
rp
.
path
}
}
req
,
err
:=
http
.
NewRequest
(
method
,
reqURL
,
body
)
req
,
err
:=
http
.
NewRequest
(
method
,
reqURL
,
body
)
...
...
src/shrpx_api_downstream_connection.cc
View file @
d48d399f
...
@@ -131,7 +131,11 @@ int APIDownstreamConnection::push_request_headers() {
...
@@ -131,7 +131,11 @@ int APIDownstreamConnection::push_request_headers() {
auto
&
req
=
downstream_
->
request
();
auto
&
req
=
downstream_
->
request
();
auto
&
resp
=
downstream_
->
response
();
auto
&
resp
=
downstream_
->
response
();
if
(
req
.
path
!=
StringRef
::
from_lit
(
"/api/v1beta1/backendconfig"
))
{
auto
path
=
StringRef
{
std
::
begin
(
req
.
path
),
std
::
find
(
std
::
begin
(
req
.
path
),
std
::
end
(
req
.
path
),
'?'
)};
if
(
path
!=
StringRef
::
from_lit
(
"/api/v1beta1/backendconfig"
))
{
send_reply
(
404
,
API_FAILURE
);
send_reply
(
404
,
API_FAILURE
);
return
0
;
return
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