Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
capnproto
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
capnproto
Commits
2e066e16
Commit
2e066e16
authored
Sep 05, 2017
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add HttpService::Response::sendError() convenience method.
parent
d2cc9fe2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
0 deletions
+23
-0
http.c++
c++/src/kj/compat/http.c++
+12
-0
http.h
c++/src/kj/compat/http.h
+11
-0
No files found.
c++/src/kj/compat/http.c++
View file @
2e066e16
...
...
@@ -2643,6 +2643,18 @@ kj::Own<HttpService> newHttpService(HttpClient& client) {
// =======================================================================================
kj
::
Promise
<
void
>
HttpService
::
Response
::
sendError
(
uint
statusCode
,
kj
::
StringPtr
statusText
,
const
HttpHeaders
&
headers
)
{
auto
stream
=
send
(
statusCode
,
statusText
,
headers
,
statusText
.
size
());
auto
promise
=
stream
->
write
(
statusText
.
begin
(),
statusText
.
size
());
return
promise
.
attach
(
kj
::
mv
(
stream
));
}
kj
::
Promise
<
void
>
HttpService
::
Response
::
sendError
(
uint
statusCode
,
kj
::
StringPtr
statusText
,
const
HttpHeaderTable
&
headerTable
)
{
return
sendError
(
statusCode
,
statusText
,
HttpHeaders
(
headerTable
));
}
kj
::
Promise
<
void
>
HttpService
::
openWebSocket
(
kj
::
StringPtr
url
,
const
HttpHeaders
&
headers
,
WebSocketResponse
&
response
)
{
class
EmptyStream
final
:
public
kj
::
AsyncInputStream
{
...
...
c++/src/kj/compat/http.h
View file @
2e066e16
...
...
@@ -518,6 +518,17 @@ public:
//
// `statusText` and `headers` need only remain valid until send() returns (they can be
// stack-allocated).
kj
::
Promise
<
void
>
sendError
(
uint
statusCode
,
kj
::
StringPtr
statusText
,
const
HttpHeaders
&
headers
);
kj
::
Promise
<
void
>
sendError
(
uint
statusCode
,
kj
::
StringPtr
statusText
,
const
HttpHeaderTable
&
headerTable
);
// Convenience wrapper around send() which sends a basic error. A generic error page specifying
// the error code is sent as the body.
//
// You must provide headers or a header table because downstream service wrappers may be
// expecting response headers built with a particular table so that they can insert additional
// headers.
};
virtual
kj
::
Promise
<
void
>
request
(
...
...
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