Skip to content

Commit

Permalink
Merge f5dab9a into 5a85512
Browse files Browse the repository at this point in the history
  • Loading branch information
AlisaLC committed Feb 4, 2022
2 parents 5a85512 + f5dab9a commit 6b11a56
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ The default behavior is `reply.send(error)`, which will be disabled if the
option is specified.
It must reply the error.

#### `rewriteHeaders(headers)`
#### `rewriteHeaders(headers, req)`

Called to rewrite the headers of the response, before them being copied
over to the outer response.
Expand Down
3 changes: 2 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ export interface FastifyReplyFromHooks {
) => void;
body?: unknown;
rewriteHeaders?: (
headers: Http2IncomingHttpHeaders | IncomingHttpHeaders
headers: Http2IncomingHttpHeaders | IncomingHttpHeaders,
req?: Http2ServerRequest | IncomingMessage
) => Http2IncomingHttpHeaders | IncomingHttpHeaders;
rewriteRequestHeaders?: (
req: Http2ServerRequest | IncomingMessage,
Expand Down
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@ module.exports = fp(function from (fastify, opts, next) {
this.request.log.info('response received')
if (sourceHttp2) {
copyHeaders(
rewriteHeaders(stripHttp1ConnectionHeaders(res.headers)),
rewriteHeaders(stripHttp1ConnectionHeaders(res.headers), req),
this
)
} else {
copyHeaders(rewriteHeaders(res.headers), this)
copyHeaders(rewriteHeaders(res.headers, req), this)
}
this.code(res.statusCode)
if (onResponse) {
Expand Down Expand Up @@ -193,7 +193,7 @@ function getQueryString (search, reqUrl, opts) {
return ''
}

function headersNoOp (headers) {
function headersNoOp (headers, originalReq) {
return headers
}

Expand Down

0 comments on commit 6b11a56

Please sign in to comment.