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
aef39484
Unverified
Commit
aef39484
authored
Oct 31, 2019
by
Kip Warner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added overload for ResponseWriter::send for raw byte stream...
parent
eb4114c8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
7 deletions
+29
-7
debian/changelog
debian/changelog
+6
-0
include/pistache/http.h
include/pistache/http.h
+19
-4
src/common/http.cc
src/common/http.cc
+3
-2
version.txt
version.txt
+1
-1
No files found.
debian/changelog
View file @
aef39484
pistache (0.0.001-git20191031-kip1) eoan; urgency=medium
* Latest upstream and first build for eoan.
-- Kip Warner <kip@thevertigo.com> Thu, 31 Oct 2019 18:23:04 -0700
pistache (0.0.001-git20191017-kip1) disco; urgency=medium
* Latest upstream.
...
...
include/pistache/http.h
View file @
aef39484
...
...
@@ -14,6 +14,7 @@
#include <algorithm>
#include <memory>
#include <string>
#include <cstddef>
#include <sys/timerfd.h>
...
...
@@ -500,13 +501,14 @@ public:
code_
=
Http
::
Code
::
Method_Not_Allowed
;
headers_
.
add
(
std
::
make_shared
<
Http
::
Header
::
Allow
>
(
supportedMethods
));
std
::
string
body
=
codeString
(
Pistache
::
Http
::
Code
::
Method_Not_Allowed
);
return
putOnWire
(
body
.
c_str
(
),
body
.
size
());
return
putOnWire
(
reinterpret_cast
<
const
std
::
byte
*>
(
body
.
c_str
()
),
body
.
size
());
}
Async
::
Promise
<
ssize_t
>
send
(
Code
code
)
{
code_
=
code
;
return
putOnWire
(
nullptr
,
0
);
}
Async
::
Promise
<
ssize_t
>
send
(
Code
code
,
const
std
::
string
&
body
,
...
...
@@ -522,7 +524,7 @@ public:
headers_
.
add
(
std
::
make_shared
<
Header
::
ContentType
>
(
mime
));
}
return
putOnWire
(
body
.
c_str
(
),
body
.
size
());
return
putOnWire
(
reinterpret_cast
<
const
std
::
byte
*>
(
body
.
c_str
()
),
body
.
size
());
}
template
<
size_t
N
>
...
...
@@ -530,6 +532,19 @@ public:
Code
code
,
const
char
(
&
arr
)[
N
],
const
Mime
::
MediaType
&
mime
=
Mime
::
MediaType
())
{
return
send
(
code
,
reinterpret_cast
<
const
std
::
byte
*>
(
arr
),
N
-
1
,
std
::
forward
<
const
Mime
::
MediaType
&>
(
mime
));
}
Async
::
Promise
<
ssize_t
>
send
(
Code
code
,
const
std
::
byte
*
data
,
const
size_t
size
,
const
Mime
::
MediaType
&
mime
=
Mime
::
MediaType
())
{
/* @Refactor: code duplication */
code_
=
code
;
...
...
@@ -542,7 +557,7 @@ public:
headers_
.
add
(
std
::
make_shared
<
Header
::
ContentType
>
(
mime
));
}
return
putOnWire
(
arr
,
N
-
1
);
return
putOnWire
(
data
,
size
);
}
ResponseStream
stream
(
Code
code
,
size_t
streamSize
=
DefaultStreamSize
)
{
...
...
@@ -609,7 +624,7 @@ private:
timeout_
.
associatePeer
(
peer_
);
}
Async
::
Promise
<
ssize_t
>
putOnWire
(
const
char
*
data
,
size_t
len
);
Async
::
Promise
<
ssize_t
>
putOnWire
(
const
std
::
byte
*
data
,
size_t
len
);
std
::
weak_ptr
<
Tcp
::
Peer
>
peer_
;
DynamicStreamBuf
buf_
;
...
...
src/common/http.cc
View file @
aef39484
...
...
@@ -16,6 +16,7 @@
#include <ctime>
#include <iomanip>
#include <unordered_map>
#include <cstddef>
#include <sys/types.h>
#include <sys/stat.h>
...
...
@@ -639,7 +640,7 @@ ResponseStream::ends() {
}
Async
::
Promise
<
ssize_t
>
ResponseWriter
::
putOnWire
(
const
char
*
data
,
size_t
len
)
ResponseWriter
::
putOnWire
(
const
std
::
byte
*
data
,
size_t
len
)
{
try
{
std
::
ostream
os
(
&
buf_
);
...
...
@@ -666,7 +667,7 @@ ResponseWriter::putOnWire(const char* data, size_t len)
OUT
(
os
<<
crlf
);
if
(
len
>
0
)
{
OUT
(
os
.
write
(
data
,
len
));
OUT
(
os
.
write
(
reinterpret_cast
<
const
char
*>
(
data
)
,
len
));
}
auto
buffer
=
buf_
.
buffer
();
...
...
version.txt
View file @
aef39484
VERSION_MAJOR 0
VERSION_MINOR 0
VERSION_PATCH 001
VERSION_GIT_DATE 201910
17
VERSION_GIT_DATE 201910
31
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