Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
B
brpc
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
brpc
Commits
48dae6ce
Commit
48dae6ce
authored
Sep 29, 2018
by
gejun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix changed function name in UT
parent
02d8790f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
+10
-10
brpc_http_message_unittest.cpp
test/brpc_http_message_unittest.cpp
+10
-10
No files found.
test/brpc_http_message_unittest.cpp
View file @
48dae6ce
...
...
@@ -333,37 +333,37 @@ TEST(HttpMessageTest, serialize_http_request) {
butil
::
IOBuf
request
;
butil
::
IOBuf
content
;
content
.
append
(
"data"
);
Serialize
HttpRequest
(
&
request
,
&
header
,
ep
,
&
content
);
MakeRaw
HttpRequest
(
&
request
,
&
header
,
ep
,
&
content
);
ASSERT_EQ
(
"POST / HTTP/1.1
\r\n
Content-Length: 4
\r\n
Host: 127.0.0.1:1234
\r\n
Foo: Bar
\r\n
Accept: */*
\r\n
User-Agent: brpc/1.0 curl/7.0
\r\n\r\n
data"
,
request
);
// user-set content-length is ignored.
header
.
SetHeader
(
"Content-Length"
,
"100"
);
Serialize
HttpRequest
(
&
request
,
&
header
,
ep
,
&
content
);
MakeRaw
HttpRequest
(
&
request
,
&
header
,
ep
,
&
content
);
ASSERT_EQ
(
"POST / HTTP/1.1
\r\n
Content-Length: 4
\r\n
Host: 127.0.0.1:1234
\r\n
Foo: Bar
\r\n
Accept: */*
\r\n
User-Agent: brpc/1.0 curl/7.0
\r\n\r\n
data"
,
request
);
// user-host overwrites passed-in remote_side
header
.
SetHeader
(
"Host"
,
"MyHost: 4321"
);
Serialize
HttpRequest
(
&
request
,
&
header
,
ep
,
&
content
);
MakeRaw
HttpRequest
(
&
request
,
&
header
,
ep
,
&
content
);
ASSERT_EQ
(
"POST / HTTP/1.1
\r\n
Content-Length: 4
\r\n
Foo: Bar
\r\n
Host: MyHost: 4321
\r\n
Accept: */*
\r\n
User-Agent: brpc/1.0 curl/7.0
\r\n\r\n
data"
,
request
);
// user-set accept
header
.
SetHeader
(
"accePT"
/*intended uppercase*/
,
"blahblah"
);
Serialize
HttpRequest
(
&
request
,
&
header
,
ep
,
&
content
);
MakeRaw
HttpRequest
(
&
request
,
&
header
,
ep
,
&
content
);
ASSERT_EQ
(
"POST / HTTP/1.1
\r\n
Content-Length: 4
\r\n
accePT: blahblah
\r\n
Foo: Bar
\r\n
Host: MyHost: 4321
\r\n
User-Agent: brpc/1.0 curl/7.0
\r\n\r\n
data"
,
request
);
// user-set UA
header
.
SetHeader
(
"user-AGENT"
,
"myUA"
);
Serialize
HttpRequest
(
&
request
,
&
header
,
ep
,
&
content
);
MakeRaw
HttpRequest
(
&
request
,
&
header
,
ep
,
&
content
);
ASSERT_EQ
(
"POST / HTTP/1.1
\r\n
Content-Length: 4
\r\n
accePT: blahblah
\r\n
user-AGENT: myUA
\r\n
Foo: Bar
\r\n
Host: MyHost: 4321
\r\n\r\n
data"
,
request
);
// user-set Authorization
header
.
SetHeader
(
"authorization"
,
"myAuthString"
);
Serialize
HttpRequest
(
&
request
,
&
header
,
ep
,
&
content
);
MakeRaw
HttpRequest
(
&
request
,
&
header
,
ep
,
&
content
);
ASSERT_EQ
(
"POST / HTTP/1.1
\r\n
Content-Length: 4
\r\n
accePT: blahblah
\r\n
user-AGENT: myUA
\r\n
authorization: myAuthString
\r\n
Foo: Bar
\r\n
Host: MyHost: 4321
\r\n\r\n
data"
,
request
);
// GET does not serialize content
header
.
set_method
(
brpc
::
HTTP_METHOD_GET
);
Serialize
HttpRequest
(
&
request
,
&
header
,
ep
,
&
content
);
MakeRaw
HttpRequest
(
&
request
,
&
header
,
ep
,
&
content
);
ASSERT_EQ
(
"GET / HTTP/1.1
\r\n
accePT: blahblah
\r\n
user-AGENT: myUA
\r\n
authorization: myAuthString
\r\n
Foo: Bar
\r\n
Host: MyHost: 4321
\r\n\r\n
"
,
request
);
}
...
...
@@ -374,7 +374,7 @@ TEST(HttpMessageTest, serialize_http_response) {
butil
::
IOBuf
response
;
butil
::
IOBuf
content
;
content
.
append
(
"data"
);
Serialize
HttpResponse
(
&
response
,
&
header
,
&
content
);
MakeRaw
HttpResponse
(
&
response
,
&
header
,
&
content
);
ASSERT_EQ
(
"HTTP/1.1 200 OK
\r\n
Content-Length: 4
\r\n
Foo: Bar
\r\n\r\n
data"
,
response
);
// content is cleared.
CHECK
(
content
.
empty
());
...
...
@@ -382,11 +382,11 @@ TEST(HttpMessageTest, serialize_http_response) {
// user-set content-length is ignored.
content
.
append
(
"data2"
);
header
.
SetHeader
(
"Content-Length"
,
"100"
);
Serialize
HttpResponse
(
&
response
,
&
header
,
&
content
);
MakeRaw
HttpResponse
(
&
response
,
&
header
,
&
content
);
ASSERT_EQ
(
"HTTP/1.1 200 OK
\r\n
Content-Length: 5
\r\n
Foo: Bar
\r\n\r\n
data2"
,
response
);
// null content
Serialize
HttpResponse
(
&
response
,
&
header
,
NULL
);
MakeRaw
HttpResponse
(
&
response
,
&
header
,
NULL
);
ASSERT_EQ
(
"HTTP/1.1 200 OK
\r\n
Foo: Bar
\r\n\r\n
"
,
response
);
}
...
...
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