Skip to content

Commit

Permalink
Fix the merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyiro committed Nov 12, 2023
1 parent 5903b0d commit 843ccb4
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/listener.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import type { IncomingMessage, ServerResponse, OutgoingHttpHeaders } from 'node:http'
import { IncomingMessage, ServerResponse } from 'node:http'
import type { OutgoingHttpHeaders } from 'node:http'
import type { Http2ServerRequest, Http2ServerResponse } from 'node:http2'
import type { Socket } from 'node:net'
import { Readable } from 'node:stream'
import type { FetchCallback } from './types'
import './globals'
Expand All @@ -9,6 +11,16 @@ import { Env } from 'hono'
const regBuffer = /^no$/i
const regContentType = /^(application\/json\b|text\/(?!event-stream\b))/i

type RequestListener = Awaited<ReturnType<typeof getRequestListener>>

export const getUpgradeListener = (requestListener: RequestListener) => {
return async (incoming: IncomingMessage, socket: Socket, head: Buffer, env?: Env['Bindings']) => {
const outgoing = new ServerResponse(incoming)
outgoing.assignSocket(socket)
return requestListener(incoming, outgoing, { incoming, socket, head, ...env })
}
}

export const getRequestListener = (fetchCallback: FetchCallback) => {
return async (
incoming: IncomingMessage | Http2ServerRequest,
Expand Down

0 comments on commit 843ccb4

Please sign in to comment.