Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia
TypeScript apiapi-clientapi-restapi-testingdeveloper-toolsgraphqlhttphttp-clientpwarestrest-apispatestingtesting-toolstoolsvuevuejswebsocket
chore: show warning for interceptors not supporting binary data (#4566)
Shreyas22515582c5a6
diff --git a/packages/hoppscotch-common/locales/en.json b/packages/hoppscotch-common/locales/en.jsonindex 61a1978cf..3a38f57eb 100644--- a/packages/hoppscotch-common/locales/en.json+++ b/packages/hoppscotch-common/locales/en.json@@ -576,7 +576,7 @@"extention_not_enabled": "Extension not enabled."},"requestBody": {- "agent_doesnt_support_binary_body": "Sending binary data via agent is not supported yet"+ "active_interceptor_doesnt_support_binary_body": "Sending binary data via the current interceptor is not supported yet."}},"layout": {diff --git a/packages/hoppscotch-common/src/platform/std/interceptors/agent/index.ts b/packages/hoppscotch-common/src/platform/std/interceptors/agent/index.tsindex a27bce5e0..d6017beb0 100644--- a/packages/hoppscotch-common/src/platform/std/interceptors/agent/index.ts+++ b/packages/hoppscotch-common/src/platform/std/interceptors/agent/index.ts@@ -271,7 +271,9 @@ export class AgentInterceptorService extends Service implements Interceptor {public selectable = { type: "selectable" as const }+ public supportsDigestAuth = truepublic supportsCookies = true+ public supportsBinaryContentType = falseprivate interceptorService = this.bind(InterceptorService)private cookieJarService = this.bind(CookieJarService)@@ -302,8 +304,6 @@ export class AgentInterceptorService extends Service implements Interceptor {public proxyInfo = ref<RequestDef["proxy"]>(undefined)- public supportsDigestAuth = true-override onServiceInit() {// Register the Root UI Extensionthis.uiExtensionService.addRootUIExtension(AgentRootUIExtension)diff --git a/packages/hoppscotch-common/src/services/inspection/inspectors/interceptors.inspector.ts b/packages/hoppscotch-common/src/services/inspection/inspectors/interceptors.inspector.tsindex b3cf0fe5f..140c72bbc 100644--- a/packages/hoppscotch-common/src/services/inspection/inspectors/interceptors.inspector.ts+++ b/packages/hoppscotch-common/src/services/inspection/inspectors/interceptors.inspector.ts@@ -40,10 +40,14 @@ export class InterceptorsInspectorService extends Service implements Inspector {const isBinaryBody =req.value.body.contentType === "application/octet-stream"- // TODO: define the supported capabilities in the interceptor- const isAgent = this.interceptors.currentInterceptorID.value === "agent"+ const currentInterceptor = this.interceptors.currentInterceptor.value- if (isBinaryBody && isAgent) {+ // TODO: Maybe move feature determination/checking related things to interceptor system.+ if (+ isBinaryBody &&+ currentInterceptor &&+ currentInterceptor.supportsBinaryContentType === false+ ) {return [{isApplicable: true,@@ -52,7 +56,7 @@ export class InterceptorsInspectorService extends Service implements Inspector {text: {type: "text",text: this.t(- "inspections.requestBody.agent_doesnt_support_binary_body"+ "inspections.requestBody.active_interceptor_doesnt_support_binary_body"),},locations: {diff --git a/packages/hoppscotch-common/src/services/interceptor.service.ts b/packages/hoppscotch-common/src/services/interceptor.service.tsindex 25a5889fd..629240f69 100644--- a/packages/hoppscotch-common/src/services/interceptor.service.ts+++ b/packages/hoppscotch-common/src/services/interceptor.service.ts@@ -104,10 +104,22 @@ export type Interceptor<Err extends InterceptorError = InterceptorError> = {/*** Defines whether the interceptor has support for cookies.- * If this field is undefined, it is assumed as not supporting cookies.+ * If this field is undefined, it is assumed as *not supporting* cookies.*/supportsCookies?: boolean+ /**+ * Defines whether the interceptor has support for Digest Auth.+ * If this field is undefined, it is assumed as *not supporting* the Digest Auth type.+ */+ supportsDigestAuth?: boolean++ /**+ * Defines whether the interceptor has support for Binary (file) content type.+ * If this field is undefined, it is assumed as *supporting* the Binary content type.+ */+ supportsBinaryContentType?: boolean+/*** Defines what to render in the Interceptor section of the Settings page.* Use this space to define interceptor specific settings.@@ -141,12 +153,6 @@ export type Interceptor<Err extends InterceptorError = InterceptorError> = {* @param request The request to run the interceptor on.*/runRequest: (request: AxiosRequestConfig) => RequestRunResult<Err>-- /**- * Defines whether the interceptor has support for Digest Auth.- * If this field is undefined, it is assumed as not supporting the Digest Auth type.- */- supportsDigestAuth?: boolean}/**diff --git a/packages/hoppscotch-selfhost-desktop/src/platform/interceptors/native/index.ts b/packages/hoppscotch-selfhost-desktop/src/platform/interceptors/native/index.tsindex c6f08cf8d..bad33e961 100644--- a/packages/hoppscotch-selfhost-desktop/src/platform/interceptors/native/index.ts+++ b/packages/hoppscotch-selfhost-desktop/src/platform/interceptors/native/index.ts@@ -260,6 +260,8 @@ export class NativeInterceptorService extends Service implements Interceptor {public selectable = { type: "selectable" as const }public supportsCookies = true+ public supportsDigestAuth = true+ public supportsBinaryContentType = falseprivate cookieJarService = this.bind(CookieJarService)private persistenceService: PersistenceService = this.bind(PersistenceService)@@ -277,8 +279,6 @@ export class NativeInterceptorService extends Service implements Interceptor {public validateCerts = ref(true)public proxyInfo = ref<RequestDef["proxy"]>(undefined)- public supportsDigestAuth = true-override onServiceInit() {// Load SSL Validationconst persistedValidateSSL: unknown = JSON.parse(