(ProtoClass, methodName, seqId, i32Value)
| 138 | // HTTP; what arrives at the browser depends on how XHR decodes the body. |
| 139 | // ───────────────────────────────────────────────────────────────────────────── |
| 140 | function 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. |
no test coverage detected