Skip to content

send_request forwards inbound Content-Type to outbound request, overriding explicitly set header #83

@geri4

Description

@geri4

Summary

Description

When a FastEdge function builds an outbound HTTP request and sets Content-Type: application/json, the header from the inbound request (Content-Type: application/x-www-form-urlencoded for form submissions) leaks through to the outbound call. The result is two Content-Type headers in the outbound request; downstream services (e.g. Telegram Bot API) see the wrong one and fail to parse the body.

Root cause: Request::builder().header(...) in the Rust http crate uses append semantics, not replace. If the outbound request is constructed from or inherits the inbound request's HeaderMap, calling .header("Content-Type", "application/json") adds a second value rather than overriding the existing one. send_request in FastEdge-sdk-rust/src/http_client.rs then forwards all headers verbatim.

Steps to reproduce

  1. Deploy a FastEdge function that receives a form POST (Content-Type: application/x-www-form-urlencoded)
  2. Build an outbound POST request with .header("Content-Type", "application/json") and a JSON body
  3. Echo the outbound request to httpbin or inspect Telegram API errors
  4. Observe: outbound Content-Type is application/x-www-form-urlencoded (or both values present), JSON body is rejected

Expected behavior

Explicitly set headers on the outbound request take precedence over any inherited inbound headers. Content-Type: application/json should be the only Content-Type forwarded.

Actual behavior

Inbound Content-Type leaks into outbound request. Telegram API returns "message text is empty" because it cannot parse the JSON body labeled as form data.

Workaround

Build the outbound request from scratch without copying inbound headers, or use HeaderMap::insert (not append) to replace the header before passing to send_request.

Affected component

FastEdge SDK (Rust) — send_request / http_client.rs

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions