api-client/packages/hoppscotch-desktop/plugin-workspace/relay
Shreyas ecf7d2507a
feat(relay): control redirect follow (#5508)
Add per-domain toggle to disable automatic HTTP redirect following in
 the Native and Agent interceptors. When disabled, requests return the
 redirect response (status code, headers, body) without following the
 Location header.

 Previously HTTP redirects were always followed (on browser, can't do
 much about that, see
 https://fetch.spec.whatwg.org/#atomic-http-redirect-handling) without
 option to inspect the redirect response itself. This prevented
 developers from accessing redirect metadata needed when testing OAuth
 flows (PKCE where intermediate responses contain authorization tokens),
 authentication endpoints that return codes in Location headers with 302
 status, and debugging API redirect chains. But on the desktop app,
 redirects were just never followed, creating the opposite effect.

 The browser's fetch API applies atomic HTTP redirect handling per spec,
 making it impossible to intercept redirects and inspect their responses.
 The Native and Agent interceptors use curl and native HTTP clients
 respectively, both supporting redirect control, making this feature
 viable for these specific interceptors. (Proxyscotch tbd).
2025-10-27 17:41:58 +05:30
..
src feat(relay): control redirect follow (#5508) 2025-10-27 17:41:58 +05:30
.envrc feat: platform independent core and the new desktop app (#4684) 2025-02-28 00:01:25 +05:30
.gitignore feat: platform independent core and the new desktop app (#4684) 2025-02-28 00:01:25 +05:30
Cargo.lock fix(kernel): deterministic form data processing (#4945) 2025-04-08 14:50:04 +05:30
Cargo.toml fix(kernel): deterministic form data processing (#4945) 2025-04-08 14:50:04 +05:30
devenv.lock feat: platform independent core and the new desktop app (#4684) 2025-02-28 00:01:25 +05:30
devenv.nix feat: platform independent core and the new desktop app (#4684) 2025-02-28 00:01:25 +05:30
devenv.yaml feat: platform independent core and the new desktop app (#4684) 2025-02-28 00:01:25 +05:30
LICENSE.md feat: platform independent core and the new desktop app (#4684) 2025-02-28 00:01:25 +05:30
README.md feat: platform independent core and the new desktop app (#4684) 2025-02-28 00:01:25 +05:30

Relay

A HTTP request-response relay used by Hoppscotch Desktop and Hoppscotch Agent for more advanced request handling including custom headers, certificates, proxies, and local system integration.

Important

This crate is only available via GitHub and not published on crates.io right now.

GitHub License MIT Rust

Installation

Add to your Cargo.toml:

[dependencies]
relay = { git = "https://github.com/CuriousCorrelation/relay.git" }

Features

  • 🦀 Blazingly fast!
  • HTTP client built on libcurl
  • HTTP/1.1, HTTP/2.0, HTTP/3.0 support
  • Security with SSL/TLS certificate management
  • Proxy support with authentication
  • Multiple authentication methods (Basic, Bearer, Digest)
  • Content handling (JSON, Form Data, Binary)
  • Custom security configurations
  • Async request execution with cancellation support

Usage

use relay::{Request, Response, execute};

let request = Request {
    id: 1,
    url: "https://api.example.com".to_string(),
    method: Method::Get,
    version: Version::Http2,
    // ... configure other options
};

let response = execute(request).await?;

Note

All requests are executed asynchronously and can be cancelled using the cancel(request_id) function.

Security Features

Tip

You can configure certificate validation, host verification, and custom certificates:

let security_config = SecurityConfig {
    validate_certificates: Some(true),
    verify_host: Some(true),
    certificates: Some(CertificateConfig {
        client: Some(CertificateType::Pem { 
            cert: cert_data,
            key: key_data 
        }),
        ca: Some(vec![ca_cert_data])
    })
};

Error Handling

The crate uses a custom error type RelayError that provides information about failures:

#[derive(Error)]
pub enum RelayError {
    Network { message: String, cause: Option<String> },
    Certificate { message: String, cause: Option<String> },
    Parse { message: String, cause: Option<String> },
    // ... other variants
}

Requirements

  • Rust 1.77.2 or later
  • OpenSSL development libraries
  • libcurl with SSL and HTTP/2.0 support

Warning

This crate uses custom forks of some dependencies for NTLM support and consistent OpenSSL backend across platforms.

License

Code: (c) 2024 - CuriousCorrelation

MIT or MIT/Apache 2.0 where applicable.