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
99cac24c
Unverified
Commit
99cac24c
authored
Aug 26, 2018
by
Dennis Jenkins
Committed by
GitHub
Aug 26, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #275 from iroddis/stream_write
Stream write
parents
438b8946
fc6e14f9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
1 deletion
+19
-1
examples/http_server.cc
examples/http_server.cc
+10
-0
include/pistache/http.h
include/pistache/http.h
+9
-1
No files found.
examples/http_server.cc
View file @
99cac24c
...
@@ -121,6 +121,16 @@ class MyHandler : public Http::Handler {
...
@@ -121,6 +121,16 @@ class MyHandler : public Http::Handler {
response
.
send
(
Http
::
Code
::
Method_Not_Allowed
);
response
.
send
(
Http
::
Code
::
Method_Not_Allowed
);
}
}
}
}
else
if
(
req
.
resource
()
==
"/stream_binary"
)
{
auto
stream
=
response
.
stream
(
Http
::
Code
::
Ok
);
char
binary_data
[]
=
"some
\0\r\n
data
\n
"
;
size_t
chunk_size
=
14
;
for
(
size_t
i
=
0
;
i
<
10
;
++
i
)
{
stream
.
write
(
binary_data
,
chunk_size
);
stream
.
flush
();
}
stream
.
ends
();
}
else
if
(
req
.
resource
()
==
"/exception"
)
{
else
if
(
req
.
resource
()
==
"/exception"
)
{
throw
std
::
runtime_error
(
"Exception thrown in the handler"
);
throw
std
::
runtime_error
(
"Exception thrown in the handler"
);
}
}
...
...
include/pistache/http.h
View file @
99cac24c
...
@@ -316,6 +316,14 @@ public:
...
@@ -316,6 +316,14 @@ public:
friend
friend
ResponseStream
&
operator
<<
(
ResponseStream
&
stream
,
const
T
&
val
);
ResponseStream
&
operator
<<
(
ResponseStream
&
stream
,
const
T
&
val
);
std
::
streamsize
write
(
const
char
*
data
,
std
::
streamsize
sz
)
{
std
::
ostream
os
(
&
buf_
);
os
<<
std
::
hex
<<
sz
<<
crlf
;
os
.
write
(
data
,
sz
);
os
<<
crlf
;
return
sz
;
}
const
Header
::
Collection
&
headers
()
const
{
const
Header
::
Collection
&
headers
()
const
{
return
headers_
;
return
headers_
;
}
}
...
...
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