MCPcopy Create free account
hub / github.com/apache/thrift / complete

Method complete

lib/cpp/src/thrift/async/TEvhttpServer.cpp:120–152  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

118}
119
120void TEvhttpServer::complete(RequestContext* ctx, bool success) {
121 (void)success;
122 std::unique_ptr<RequestContext> ptr(ctx);
123
124 int code = success ? 200 : 400;
125 const char* reason = success ? "OK" : "Bad Request";
126
127 int rv = evhttp_add_header(ctx->req->output_headers, "Content-Type", "application/x-thrift");
128 if (rv != 0) {
129 // TODO: Log an error.
130 std::cerr << "evhttp_add_header failed " << __FILE__ << ":" << __LINE__ << '\n';
131 }
132
133 struct evbuffer* buf = evbuffer_new();
134 if (buf == nullptr) {
135 // TODO: Log an error.
136 std::cerr << "evbuffer_new failed " << __FILE__ << ":" << __LINE__ << '\n';
137 } else {
138 uint8_t* obuf;
139 uint32_t sz;
140 ctx->obuf->getBuffer(&obuf, &sz);
141 int ret = evbuffer_add(buf, obuf, sz);
142 if (ret != 0) {
143 // TODO: Log an error.
144 std::cerr << "evhttp_add failed with " << ret << " " << __FILE__ << ":" << __LINE__ << '\n';
145 }
146 }
147
148 evhttp_send_reply(ctx->req, code, reason, buf);
149 if (buf != nullptr) {
150 evbuffer_free(buf);
151 }
152}
153
154struct event_base* TEvhttpServer::getEventBase() {
155 return eb_;

Callers 4

test-jq.jsFile · 0.80
setServingMethod · 0.80
onCompleteMethod · 0.80
onCompleteMethod · 0.80

Calls 1

getBufferMethod · 0.45

Tested by 2

setServingMethod · 0.64
onCompleteMethod · 0.64