Skip to content

Commit

Permalink
refactor: remove noisy logs
Browse files Browse the repository at this point in the history
  • Loading branch information
metcoder95 committed May 10, 2023
1 parent 7661b05 commit 2206c52
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
2 changes: 1 addition & 1 deletion lib/api/api-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class RequestHandler extends AsyncResource {

this.callback = null
this.res = body

// console.log('called', callback !== null)
if (callback !== null) {
if (this.throwOnError && statusCode >= 400) {
this.runInAsyncScope(getResolveErrorBodyCallback, null,
Expand Down
26 changes: 13 additions & 13 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -1116,6 +1116,7 @@ async function connect (client) {

assert(socket)

// console.log(socket)
if (socket.alpnProtocol === 'h2') {
const session = http2.connect(client[kUrl], {
createConnection: () => socket
Expand Down Expand Up @@ -1371,7 +1372,7 @@ function _resume (client, sync) {

function write (client, request) {
if (client[kHTTP2Session]) {
console.log('http/2')
// console.log('http/2')
writeH2(client, client[kHTTP2Session], request)
return
}
Expand Down Expand Up @@ -1613,7 +1614,7 @@ function writeH2 (client, session, request) {

stream.on('continue', () => {
// TODO[H2]: Shall we trigger an event when 100-continue operations
console.log('this is the body:', body)
// console.log('this is the body:', body)
/* istanbul ignore else: assertion */
if (!body) {
if (contentLength === 0) {
Expand All @@ -1625,16 +1626,16 @@ function writeH2 (client, session, request) {

request.onRequestSent()
} else if (util.isBuffer(body)) {
console.log('as buffer')
// console.log('as buffer')
assert(contentLength === body.byteLength, 'buffer body must have content length')

headers['content-length'] = `${contentLength}`
stream.end(body)
request.onBodySent(body)
request.onRequestSent()
console.log('ended?')
// console.log('ended?')
} else if (util.isBlob(body)) {
console.log('as blob')
// console.log('as blob')
if (typeof body.stream === 'function') {
writeIterable({ body: body.stream(), client, request, socket: client[kSocket], contentLength, expectsPayload })
} else {
Expand Down Expand Up @@ -1663,16 +1664,15 @@ function writeH2 (client, session, request) {

request.onRequestSent()
} else if (util.isBuffer(body)) {
console.log('as buffer')
// console.log('as buffer')
assert(contentLength === body.byteLength, 'buffer body must have content length')

headers['content-length'] = `${contentLength}`
stream.end(body)
request.onBodySent(body)
request.onRequestSent()
console.log('ended?')
} else if (util.isBlob(body)) {
console.log('as blob')
} else if (util.isBlobLike(body)) {
// console.log('as blob')
if (typeof body.stream === 'function') {
writeIterable({ body: body.stream(), client, request, socket: client[kSocket], contentLength, expectsPayload })
} else {
Expand Down Expand Up @@ -1710,12 +1710,11 @@ function writeH2 (client, session, request) {
}
}

console.log('http/2 request')
// TODO(HTTP/2): ref only if current streams count is 0
session.ref()
const stream = session.request(headers)
// console.log('http/2 request')
// const stream = session.request(headers)

stream.on('response', headers => {
// console.log('h2 response:', headers)
if (request.onHeaders(Number(headers[':status']), headers, stream.resume.bind(stream), '') === false) {
stream.pause()
}
Expand Down Expand Up @@ -1748,6 +1747,7 @@ function writeH2 (client, session, request) {

stream.on('close', () => {
// TODO(HTTP/2): unref only if current streams count is 0
// console.log('closed?')
session.unref()
})

Expand Down
2 changes: 0 additions & 2 deletions test/http2.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,6 @@ test('Should handle h2 request with body (stream)', async t => {
t.equal(headers[':path'], '/')
t.equal(headers[':scheme'], 'https')

console.log('request received and valid')

stream.on('data', chunk => requestChunks.push(chunk))

stream.respond({
Expand Down

0 comments on commit 2206c52

Please sign in to comment.