Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pistache
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
pistache
Commits
61f42550
Commit
61f42550
authored
May 15, 2016
by
octal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Client will now detect when the remote closes the connection
parent
0c3af626
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
7 deletions
+22
-7
include/client.h
include/client.h
+1
-0
src/client/client.cc
src/client/client.cc
+21
-7
No files found.
include/client.h
View file @
61f42550
...
...
@@ -94,6 +94,7 @@ struct Connection : public std::enable_shared_from_this<Connection> {
Fd
fd
;
void
handleResponsePacket
(
const
char
*
buffer
,
size_t
totalBytes
);
void
handleError
(
const
char
*
error
);
void
handleTimeout
();
std
::
string
dump
()
const
;
...
...
src/client/client.cc
View file @
61f42550
...
...
@@ -42,7 +42,7 @@ splitUrl(const std::string& url) {
match_literal
(
'.'
,
cursor
);
StreamCursor
::
Token
hostToken
(
cursor
);
match_until
(
'/'
,
cursor
);
match_until
(
{
'?'
,
'/'
}
,
cursor
);
StringView
host
(
hostToken
.
rawText
(),
hostToken
.
size
());
StringView
page
(
cursor
.
offset
(),
buf
.
endptr
());
...
...
@@ -114,8 +114,12 @@ namespace {
auto
host
=
s
.
first
;
auto
path
=
s
.
second
;
auto
pathStr
=
path
.
toString
();
OUT
(
os
<<
request
.
method
()
<<
" "
);
OUT
(
os
<<
path
.
toString
());
if
(
pathStr
[
0
]
!=
'/'
)
OUT
(
os
<<
'/'
);
OUT
(
os
<<
pathStr
);
OUT
(
os
<<
" HTTP/1.1"
<<
crlf
);
if
(
!
writeCookies
(
request
.
cookies
(),
buf
))
return
false
;
...
...
@@ -322,17 +326,15 @@ Transport::handleIncoming(const std::shared_ptr<Connection>& connection) {
handleResponsePacket
(
connection
,
buffer
,
totalBytes
);
}
}
else
{
if
(
errno
==
ECONNRESET
)
{
}
else
{
throw
std
::
runtime_error
(
strerror
(
errno
));
}
connection
->
handleError
(
strerror
(
errno
));
}
break
;
}
else
if
(
bytes
==
0
)
{
if
(
totalBytes
>
0
)
{
handleResponsePacket
(
connection
,
buffer
,
totalBytes
);
}
else
{
connection
->
handleError
(
"Remote closed connection"
);
}
connections
.
erase
(
connection
->
fd
);
connection
->
close
();
...
...
@@ -462,6 +464,18 @@ Connection::handleResponsePacket(const char* buffer, size_t bytes) {
}
}
void
Connection
::
handleError
(
const
char
*
error
)
{
auto
req
=
std
::
move
(
inflightRequests
.
front
());
if
(
req
.
timer
)
{
req
.
timer
->
disarm
();
timerPool_
.
releaseTimer
(
req
.
timer
);
}
req
.
reject
(
Net
::
Error
(
error
));
req
.
onDone
();
}
void
Connection
::
handleTimeout
()
{
auto
req
=
std
::
move
(
inflightRequests
.
front
());
...
...
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