hono-problem-details 0.12.1 → 0.12.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -612,6 +612,12 @@ problemDetailsHandler({
612
612
  });
613
613
  ```
614
614
 
615
+ > **Note on a throw after `await next()`**: the route's response already exists at that point, and
616
+ > Hono copies its headers onto whatever `onError` returns, except `Content-Type`. Behind `compress()`,
617
+ > this can send `Content-Encoding: gzip` on an uncompressed problem body, which clients cannot decode.
618
+ > Any `onError` handler is affected, not only this one. To avoid it, throw before the response is
619
+ > produced, or register `compress()` outside the middleware that throws.
620
+
615
621
  ## Used By
616
622
 
617
623
  The following Hono middleware libraries use `hono-problem-details` as an optional dependency for RFC 9457 error responses:
package/dist/index.cjs CHANGED
@@ -183,11 +183,22 @@ function getOtelTraceId(api) {
183
183
 
184
184
  // src/handler.ts
185
185
  var REPRESENTATION_HEADERS = /* @__PURE__ */ new Set([
186
- "transfer-encoding",
186
+ "content-type",
187
+ "content-encoding",
188
+ "content-language",
189
+ "content-length",
190
+ "content-location",
191
+ "content-range",
192
+ "content-disposition",
193
+ "content-md5",
194
+ "content-digest",
195
+ "content-signature",
196
+ "repr-digest",
197
+ "digest",
187
198
  "etag",
188
199
  "last-modified",
189
- "digest",
190
- "accept-ranges"
200
+ "accept-ranges",
201
+ "transfer-encoding"
191
202
  ]);
192
203
  function buildType(status, options) {
193
204
  if (options.typePrefix) {
@@ -199,7 +210,7 @@ function buildType(status, options) {
199
210
  function copyResHeaders(error, response) {
200
211
  if (error instanceof import_http_exception.HTTPException) {
201
212
  error.res?.headers.forEach((value, name) => {
202
- if (!name.startsWith("content-") && !REPRESENTATION_HEADERS.has(name)) {
213
+ if (!REPRESENTATION_HEADERS.has(name)) {
203
214
  response.headers.append(name, value);
204
215
  }
205
216
  });
package/dist/index.js CHANGED
@@ -32,11 +32,22 @@ function getOtelTraceId(api) {
32
32
 
33
33
  // src/handler.ts
34
34
  var REPRESENTATION_HEADERS = /* @__PURE__ */ new Set([
35
- "transfer-encoding",
35
+ "content-type",
36
+ "content-encoding",
37
+ "content-language",
38
+ "content-length",
39
+ "content-location",
40
+ "content-range",
41
+ "content-disposition",
42
+ "content-md5",
43
+ "content-digest",
44
+ "content-signature",
45
+ "repr-digest",
46
+ "digest",
36
47
  "etag",
37
48
  "last-modified",
38
- "digest",
39
- "accept-ranges"
49
+ "accept-ranges",
50
+ "transfer-encoding"
40
51
  ]);
41
52
  function buildType(status, options) {
42
53
  if (options.typePrefix) {
@@ -48,7 +59,7 @@ function buildType(status, options) {
48
59
  function copyResHeaders(error, response) {
49
60
  if (error instanceof HTTPException) {
50
61
  error.res?.headers.forEach((value, name) => {
51
- if (!name.startsWith("content-") && !REPRESENTATION_HEADERS.has(name)) {
62
+ if (!REPRESENTATION_HEADERS.has(name)) {
52
63
  response.headers.append(name, value);
53
64
  }
54
65
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hono-problem-details",
3
- "version": "0.12.1",
3
+ "version": "0.12.2",
4
4
  "description": "RFC 9457 Problem Details middleware for Hono",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",