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

Function encodeServerReply

lib/nodejs/test/thrift_4987_xhr_protocol.test.mjs:140–157  ·  view source on GitHub ↗
(ProtoClass, methodName, seqId, i32Value)

Source from the content-addressed store, hash-verified

138// HTTP; what arrives at the browser depends on how XHR decodes the body.
139// ─────────────────────────────────────────────────────────────────────────────
140function encodeServerReply(ProtoClass, methodName, seqId, i32Value) {
141 let encoded = null;
142 const t = new TBufferedTransport(null, (buf) => {
143 encoded = buf;
144 });
145 const p = new ProtoClass(t);
146 p.writeMessageBegin(methodName, Thrift.MessageType.REPLY, seqId);
147 p.writeStructBegin("testI32_result");
148 p.writeFieldBegin("success", Thrift.Type.I32, 0);
149 p.writeI32(i32Value);
150 p.writeFieldEnd();
151 p.writeFieldStop();
152 p.writeStructEnd();
153 p.writeMessageEnd();
154 t.flush();
155 if (!encoded) throw new Error("TBufferedTransport did not flush");
156 return encoded;
157}
158
159// ─────────────────────────────────────────────────────────────────────────────
160// MockXHR — drop-in replacement for the browser XMLHttpRequest object.

Callers 1

runScenarioFunction · 0.85

Calls 9

flushMethod · 0.95
writeMessageBeginMethod · 0.65
writeStructBeginMethod · 0.65
writeFieldBeginMethod · 0.65
writeI32Method · 0.65
writeFieldEndMethod · 0.65
writeFieldStopMethod · 0.65
writeStructEndMethod · 0.65
writeMessageEndMethod · 0.65

Tested by

no test coverage detected