Commit 443ac893 authored by Kenton Varda's avatar Kenton Varda

Don't throw from ~HttpChunkedEntityWriter after write cancellation.

In theory KJ style should allow this to be caught (it doesn't throw if another exception was already thrown), but I've observed this producing an std::terminate() for some reason.
parent abb19c3c
......@@ -1610,6 +1610,10 @@ public:
return !inBody && !broken && !writeInProgress;
}
bool canWriteBodyData() {
return !writeInProgress && inBody;
}
void writeHeaders(String content) {
// Writes some header content and begins a new entity body.
......@@ -1833,8 +1837,12 @@ public:
HttpChunkedEntityWriter(HttpOutputStream& inner)
: inner(inner) {}
~HttpChunkedEntityWriter() noexcept(false) {
inner.writeBodyData(kj::str("0\r\n\r\n"));
inner.finishBody();
if (inner.canWriteBodyData()) {
inner.writeBodyData(kj::str("0\r\n\r\n"));
inner.finishBody();
} else {
inner.abortBody();
}
}
Promise<void> write(const void* buffer, size_t size) override {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment