You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// format headers in chosen reqResObj so we can add them to our request
145
147
constformattedHeaders={};
146
148
reqResObj.request.headers.forEach((head)=>{
147
149
formattedHeaders[head.key]=head.value;
@@ -150,15 +152,11 @@ const httpController = {
150
152
151
153
// initiate request
152
154
constreqStream=client.request(formattedHeaders,{
155
+
// do not immediately close the *writable* side of the http2 stream (i.e. what the request sends over), in case we are using a request method that sends a payload body
153
156
endStream: false,
154
157
});
155
158
156
-
console.log("reqStream at THIS moment : ",{
157
-
...reqStream,
158
-
});
159
-
160
-
// endStream false means we can continue to send more data, which we would for a body;
161
-
// Send body depending on method;
159
+
// we can now close the writable side of our stream, either sending our request body or not, depending on our method
162
160
if(
163
161
reqResObj.request.method!=="GET"&&
164
162
reqResObj.request.method!=="HEAD"
@@ -169,10 +167,11 @@ const httpController = {
169
167
reqStream.end();
170
168
}
171
169
172
-
console.log("reqStream at THIS moment : ",{
173
-
...reqStream,
174
-
});
170
+
// console.log("reqStream at THIS moment : ", {
171
+
// ...reqStream,
172
+
// });
175
173
174
+
// create an object that represents our open connection.
176
175
constopenConnectionObj={
177
176
stream: reqStream,
178
177
protocol: "HTTP2",
@@ -185,11 +184,14 @@ const httpController = {
185
184
" openConnectionObj : ",
186
185
JSON.parse(JSON.stringify(openConnectionObj))
187
186
);
187
+
188
+
// this is the connection array that was passed into these controller functions from reqResController.js
188
189
connectionArray.push(openConnectionObj);
189
190
190
191
letisSSE;
191
192
192
193
reqStream.on("response",(headers,flags)=>{
194
+
// first argumnet of callback to response listener in ClientHttp2Stream is an object containing the receieved HTTP/2 Headers Object, as well as the flags associated with those headers
193
195
isSSE=headers["content-type"].includes("stream");
194
196
195
197
if(isSSE){
@@ -201,24 +203,28 @@ const httpController = {
201
203
}
202
204
reqResObj.isHTTP2=true;
203
205
reqResObj.timeReceived=Date.now();
206
+
console.log('this is the time inside the response event listener : ',Date.now())
204
207
reqResObj.response.headers=headers;
205
208
// reqResObj.response.events = []; // passing empty array to handleSingleEvent
206
209
// below instead of running this line. This invocation is different from
207
210
// when it is run below to Check if the URL provided is a stream (near line 327)
0 commit comments