Skip to content

Commit 8b75121

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

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,18 @@ 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 expectedEvent = "response";
171+
172+
if (options.headers?.Expect) {
173+
expectedEvent = "continue";
174+
}
175+
176+
this.logger.debug("making request and waiting for event", options, expectedEvent);
177+
171178
const clientRequest = httpRequest({ ...options, agent: this.agent })
172-
.on("response", (incomingMessage: IncomingMessage) => {
173-
this.logger.debug("Got Response", options);
179+
.on(expectedEvent, (incomingMessage: IncomingMessage) => {
180+
this.logger.debug(`Got event ${expectedEvent}`);
174181
resolve({ incomingMessage, clientRequest });
175182
})
176183
.on("error", (error: Error) => {

0 commit comments

Comments
 (0)