Skip to main content

http_request

Function http_request 

Source
pub fn http_request(
    method: Method,
    url: &str,
    headers: &[(String, String)],
    body: Option<&[u8]>,
) -> Result<HttpResponse, String>
Expand description

Perform a synchronous HTTP request via bun_http::AsyncHTTP::send_sync().

This function:

  1. Parses the URL via bun_url::URL::parse
  2. Builds request headers via HeaderBuilder
  3. Initializes AsyncHTTP via init_sync()
  4. Executes the request via send_sync() (blocking)
  5. Extracts the response into an owned HttpResponse