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
fabfc0b2
Commit
fabfc0b2
authored
Mar 05, 2012
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #13 from sorced-jim/master
spdycat should fail for failed requests
parents
8fd2fabe
541b6e9b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
12 deletions
+29
-12
examples/SpdyServer.cc
examples/SpdyServer.cc
+6
-3
examples/spdycat.cc
examples/spdycat.cc
+16
-9
tests/end_to_end.py
tests/end_to_end.py
+7
-0
No files found.
examples/SpdyServer.cc
View file @
fabfc0b2
...
...
@@ -263,13 +263,15 @@ int SpdyEventHandler::submit_file_response(const std::string& status,
off_t
file_length
,
spdylay_data_provider
*
data_prd
)
{
std
::
string
date_str
=
util
::
http_date
(
time
(
0
));
std
::
string
content_length
=
util
::
to_str
(
file_length
);
const
char
*
nv
[]
=
{
get_header_field
(
version_
,
HD_STATUS
).
c_str
(),
status
.
c_str
(),
get_header_field
(
version_
,
HD_VERSION
).
c_str
(),
"HTTP/1.1"
,
"server"
,
SPDYD_SERVER
.
c_str
(),
"content-length"
,
util
::
to_str
(
file_length
)
.
c_str
(),
"content-length"
,
content_length
.
c_str
(),
"cache-control"
,
"max-age=3600"
,
"date"
,
util
::
http_date
(
time
(
0
))
.
c_str
(),
"date"
,
date_str
.
c_str
(),
0
,
0
,
0
};
...
...
@@ -286,6 +288,7 @@ int SpdyEventHandler::submit_response
const
std
::
vector
<
std
::
pair
<
std
::
string
,
std
::
string
>
>&
headers
,
spdylay_data_provider
*
data_prd
)
{
std
::
string
date_str
=
util
::
http_date
(
time
(
0
));
const
char
**
nv
=
new
const
char
*
[
8
+
headers
.
size
()
*
2
+
1
];
nv
[
0
]
=
get_header_field
(
version_
,
HD_STATUS
).
c_str
();
nv
[
1
]
=
status
.
c_str
();
...
...
@@ -294,7 +297,7 @@ int SpdyEventHandler::submit_response
nv
[
4
]
=
"server"
;
nv
[
5
]
=
SPDYD_SERVER
.
c_str
();
nv
[
6
]
=
"date"
;
nv
[
7
]
=
util
::
http_date
(
time
(
0
))
.
c_str
();
nv
[
7
]
=
date_str
.
c_str
();
for
(
int
i
=
0
;
i
<
(
int
)
headers
.
size
();
++
i
)
{
nv
[
8
+
i
*
2
]
=
headers
[
i
].
first
.
c_str
();
nv
[
8
+
i
*
2
+
1
]
=
headers
[
i
].
second
.
c_str
();
...
...
examples/spdycat.cc
View file @
fabfc0b2
...
...
@@ -161,10 +161,13 @@ int communicate(const std::string& host, uint16_t port,
}
make_non_block
(
fd
);
set_tcp_nodelay
(
fd
);
Spdylay
sc
(
fd
,
ssl
,
spdylay_npn_get_version
(
reinterpret_cast
<
const
unsigned
char
*>
(
next_proto
.
c_str
()),
next_proto
.
size
()),
callbacks
);
int
spdy_version
=
spdylay_npn_get_version
(
reinterpret_cast
<
const
unsigned
char
*>
(
next_proto
.
c_str
()),
next_proto
.
size
());
if
(
spdy_version
<=
0
)
{
return
-
1
;
}
Spdylay
sc
(
fd
,
ssl
,
spdy_version
,
callbacks
);
nfds_t
npollfds
=
1
;
pollfd
pollfds
[
1
];
...
...
@@ -243,12 +246,15 @@ int run(char **uris, int n)
std
::
vector
<
Request
>
reqvec
;
std
::
string
prev_host
;
uint16_t
prev_port
=
0
;
int
failures
=
0
;
for
(
int
i
=
0
;
i
<
n
;
++
i
)
{
uri
::
UriStruct
us
;
if
(
uri
::
parse
(
us
,
uris
[
i
]))
{
if
(
prev_host
!=
us
.
host
||
prev_port
!=
us
.
port
)
{
if
(
!
reqvec
.
empty
())
{
communicate
(
prev_host
,
prev_port
,
reqvec
,
&
callbacks
);
if
(
communicate
(
prev_host
,
prev_port
,
reqvec
,
&
callbacks
)
!=
0
)
{
++
failures
;
}
reqvec
.
clear
();
}
prev_host
=
us
.
host
;
...
...
@@ -258,9 +264,11 @@ int run(char **uris, int n)
}
}
if
(
!
reqvec
.
empty
())
{
communicate
(
prev_host
,
prev_port
,
reqvec
,
&
callbacks
);
if
(
communicate
(
prev_host
,
prev_port
,
reqvec
,
&
callbacks
)
!=
0
)
{
++
failures
;
}
}
return
0
;
return
failures
;
}
void
print_usage
(
std
::
ostream
&
out
)
...
...
@@ -330,8 +338,7 @@ int main(int argc, char **argv)
SSL_load_error_strings
();
SSL_library_init
();
reset_timer
();
run
(
argv
+
optind
,
argc
-
optind
);
return
0
;
return
run
(
argv
+
optind
,
argc
-
optind
);
}
}
// namespace spdylay
...
...
tests/end_to_end.py
View file @
fabfc0b2
...
...
@@ -76,6 +76,13 @@ class EndToEndSpdy2Tests(EndToEndSpdyTests):
self
.
assertEquals
(
0
,
self
.
call
(
'/'
,
[
'-v'
,
'-3'
]))
self
.
assertIn
(
'NPN selected the protocol: spdy/3'
,
self
.
stdout
)
def
testFailedRequests
(
self
):
self
.
assertEquals
(
2
,
self
.
call
(
'/'
,
[
'https://localhost:25/'
,
'http://localhost:79'
]))
def
testOneFailedRequest
(
self
):
self
.
assertEquals
(
1
,
subprocess
.
call
([
self
.
client
,
'http://localhost:2/'
]))
class
EndToEndSpdy3Tests
(
EndToEndSpdyTests
):
@
classmethod
...
...
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