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

Function processPost

lib/nodejs/lib/thrift/web_server.js:378–429  ·  view source on GitHub ↗
(request, response)

Source from the content-addressed store, hash-verified

376 //Handle POST methods (TXHRTransport)
377 ///////////////////////////////////////////////////
378 function processPost(request, response) {
379 //Lookup service
380 var uri = url.parse(request.url).pathname;
381 var svc = services[uri];
382 if (!svc) {
383 response.writeHead("403", "No Apache Thrift Service at " + uri, {});
384 response.end();
385 return;
386 }
387
388 //Verify CORS requirements
389 if (!VerifyCORSAndSetHeaders(request, response)) {
390 response.writeHead(
391 "403",
392 "Origin " + request.headers.origin + " not allowed",
393 {},
394 );
395 response.end();
396 return;
397 }
398
399 //Process XHR payload
400 request.on(
401 "data",
402 svc.transport.receiver(function (transportWithData) {
403 var input = new svc.protocol(transportWithData);
404 var output = new svc.protocol(
405 new svc.transport(undefined, function (buf) {
406 try {
407 response.writeHead(200);
408 response.end(buf);
409 } catch (err) {
410 response.writeHead(500);
411 response.end();
412 }
413 }),
414 );
415
416 try {
417 svc.processor.process(input, output);
418 transportWithData.commitPosition();
419 } catch (err) {
420 if (err instanceof InputBufferUnderrunError) {
421 transportWithData.rollbackPosition();
422 } else {
423 response.writeHead(500);
424 response.end();
425 }
426 }
427 }),
428 );
429 }
430
431 //Handle GET methods (Static Page Server)
432 ///////////////////////////////////////////////////

Callers 1

web_server.jsFile · 0.85

Calls 4

VerifyCORSAndSetHeadersFunction · 0.85
parseMethod · 0.80
processMethod · 0.65
endMethod · 0.45

Tested by

no test coverage detected