@bufbuild/connect
Advanced tools
Comparing version 0.10.1 to 0.11.0
@@ -21,2 +21,3 @@ "use strict"; | ||
const connect_error_js_1 = require("../connect-error.js"); | ||
const content_type_js_1 = require("./content-type.js"); | ||
const headers_js_1 = require("./headers.js"); | ||
@@ -34,5 +35,8 @@ /** | ||
function validateResponse(methodKind, status, headers) { | ||
const mimeType = headers.get("Content-Type"); | ||
const parsedType = (0, content_type_js_1.parseContentType)(mimeType); | ||
if (status !== 200) { | ||
const errorFromStatus = new connect_error_js_1.ConnectError(`HTTP ${status}`, (0, http_status_js_1.codeFromHttpStatus)(status), headers); | ||
if (methodKind == protobuf_1.MethodKind.Unary) { | ||
// If parsedType is defined and it is not binary, then this is a unary JSON response | ||
if (methodKind == protobuf_1.MethodKind.Unary && parsedType && !parsedType.binary) { | ||
return { isUnaryError: true, unaryError: errorFromStatus }; | ||
@@ -39,0 +43,0 @@ } |
@@ -18,2 +18,3 @@ // Copyright 2021-2023 Buf Technologies, Inc. | ||
import { ConnectError } from "../connect-error.js"; | ||
import { parseContentType } from "./content-type.js"; | ||
import { headerStreamEncoding, headerUnaryEncoding } from "./headers.js"; | ||
@@ -31,5 +32,8 @@ /** | ||
export function validateResponse(methodKind, status, headers) { | ||
const mimeType = headers.get("Content-Type"); | ||
const parsedType = parseContentType(mimeType); | ||
if (status !== 200) { | ||
const errorFromStatus = new ConnectError(`HTTP ${status}`, codeFromHttpStatus(status), headers); | ||
if (methodKind == MethodKind.Unary) { | ||
// If parsedType is defined and it is not binary, then this is a unary JSON response | ||
if (methodKind == MethodKind.Unary && parsedType && !parsedType.binary) { | ||
return { isUnaryError: true, unaryError: errorFromStatus }; | ||
@@ -36,0 +40,0 @@ } |
{ | ||
"name": "@bufbuild/connect", | ||
"version": "0.10.1", | ||
"version": "0.11.0", | ||
"description": "Type-safe APIs with Protobuf and TypeScript.", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
725397
15630