Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Infiniflow Ragflow Http Client

From Leeroopedia
Knowledge Sources
Domains Networking, Infrastructure
Last Updated 2026-02-12 06:00 GMT

Overview

Concrete tool providing centralized async and synchronous HTTP clients with retry logic, exponential backoff, and credential masking for the RAGFlow backend.

Description

The http_client module wraps httpx to provide async_request and sync_request functions with configurable retries, exponential backoff, timeout handling, proxy support, and automatic redaction of sensitive URL parameters and OAuth endpoints in log output.

Usage

Import async_request for non-blocking HTTP calls in async handlers (e.g., LLM API calls) or sync_request for blocking calls in synchronous code paths.

Code Reference

Source Location

Signature

async def async_request(
    method: str, url: str, *,
    request_timeout: float = None,
    headers: dict = None,
    auth_token: str = None,
    retries: int = None,
    backoff_factor: float = None,
    proxy: str = None,
    **kwargs,
) -> httpx.Response:
    """Async HTTP request with retry and backoff."""

def sync_request(
    method: str, url: str, *,
    timeout: float = None,
    headers: dict = None,
    auth_token: str = None,
    retries: int = None,
    backoff_factor: float = None,
    proxy: str = None,
    **kwargs,
) -> httpx.Response:
    """Synchronous HTTP request with retry and backoff."""

Import

from common.http_client import async_request, sync_request

I/O Contract

Inputs

Name Type Required Description
method str Yes HTTP method (GET, POST, PUT, DELETE)
url str Yes Target URL
request_timeout float No Request timeout in seconds
retries int No Maximum retry attempts
backoff_factor float No Exponential backoff multiplier
auth_token str No Bearer token for Authorization header

Outputs

Name Type Description
returns httpx.Response HTTP response object

Usage Examples

from common.http_client import async_request, sync_request

# Async request to LLM API
response = await async_request(
    "POST", "https://api.openai.com/v1/chat/completions",
    auth_token="sk-...",
    json={"model": "gpt-4", "messages": [{"role": "user", "content": "Hello"}]},
    request_timeout=30,
    retries=3,
)

# Sync request
resp = sync_request("GET", "http://localhost:9380/api/v1/health")

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment