Skip to content

Commit f461212

Browse files
committed
Fix makeRequest when sending expect: 100-continue
1 parent 0ff92ec commit f461212

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

packages/verser/src/lib/verser-connection.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,18 +166,26 @@ export class VerserConnection {
166166
public async makeRequest(options: RequestOptions): Promise<VerserRequestResult> {
167167
if (!this.connected) throw new Error("Not connected");
168168

169-
this.logger.debug("making request", options);
170169
return new Promise((resolve, reject) => {
170+
let resolveEventName = "response";
171+
172+
if (options.headers?.Expect) {
173+
resolveEventName = "continue";
174+
}
175+
176+
this.logger.debug("making request and waiting for event", options, resolveEventName);
177+
171178
const clientRequest = httpRequest({ ...options, agent: this.agent })
172-
.on("response", (incomingMessage: IncomingMessage) => {
173-
this.logger.debug("Got Response", options);
179+
.on(resolveEventName, (incomingMessage: IncomingMessage) => {
180+
this.logger.debug(`Got event ${resolveEventName}`);
174181
resolve({ incomingMessage, clientRequest });
175182
})
176183
.on("error", (error: Error) => {
177184
this.logger.error("Request error", options, error);
178185
reject(error);
179186
});
180187

188+
clientRequest.setNoDelay(true);
181189
clientRequest.setSocketKeepAlive(true);
182190
clientRequest.flushHeaders();
183191

0 commit comments

Comments
 (0)