Skip to content

xh receives 400 Bad Request with the default http-version #435

@recsubbu

Description

@recsubbu

Hi,

Thanks for this wonderful tool.

macOS (Monterey)
python 3.13
uvicorn 0.34.0

$ xh -V
xh 0.25.0

uvicorn serves HTTP 1.1 well for browser requests.

INFO: 127.0.0.1:57380 - "GET / HTTP/1.1" 200 OK

But, xh gets a 400 bad request.

$ xh localhost:5001
HTTP/1.1 400 Bad Request
Connection: close
Content-Length: 30
Content-Type: text/plain; charset=utf-8
Date: Thu, 27 Nov 2025 11:05:53 GMT
Server: uvicorn

Invalid HTTP request received.

HTTP 1.0 is works fine.

$ xh --http-version 1 localhost:5001
HTTP/1.1 200 OK
Content-Length: 3254
Content-Type: text/html; charset=utf-8
Date: Thu, 27 Nov 2025 11:14:43 GMT
Server: uvicorn

Debug output:

$ xh --debug localhost:5001
[0.000020s DEBUG xh] xh 0.25.0 -native-tls +rustls
[0.000071s DEBUG xh] Cli {
httpie_compat_mode: false,
json: false,
form: false,
multipart: false,
raw: None,
pretty: None,
format_options: [],
style: None,
response_charset: None,
response_mime: None,
print: None,
headers: false,
body: false,
meta: false,
verbose: 0,
debug: true,
all: false,
history_print: None,
quiet: 0,
stream_raw: false,
compress: 0,
stream: None,
output: None,
download: false,
resume: false,
session: None,
session_read_only: None,
is_session_read_only: false,
auth_type: None,
auth: None,
bearer: None,
ignore_netrc: false,
offline: false,
check_status_raw: false,
check_status: None,
follow: false,
max_redirects: None,
timeout: None,
proxy: [],
verify: None,
cert: None,
cert_key: None,
ssl: None,
native_tls: false,
default_scheme: None,
https: false,
http_version: None,
resolve: [],
interface: None,
ipv4: false,
ipv6: false,
unix_socket: None,
ignore_stdin: false,
curl: false,
curl_long: false,
generate: None,
help: None,
raw_method_or_url: Some(
"localhost:5001",
),
raw_rest_args: [],
method: None,
url: Url {
scheme: "http",
cannot_be_a_base: false,
username: "",
password: None,
host: Some(
Domain(
"localhost",
),
),
port: Some(
5001,
),
path: "/",
query: None,
fragment: None,
},
request_items: RequestItems {
items: [],
body_type: Json,
},
bin_name: "xh",
}
[0.000238s DEBUG xh] Complete URL: http://localhost:5001/
[0.000261s DEBUG xh] HTTP method: GET
[0.560407s DEBUG reqwest::connect] starting new connection: http://localhost:5001/
[0.561567s DEBUG hyper_util::client::legacy::connect::http] connecting to [::1]:5001
[0.561881s DEBUG hyper_util::client::legacy::connect::http] connecting to 127.0.0.1:5001
[0.562092s DEBUG hyper_util::client::legacy::connect::http] connected to 127.0.0.1:5001
HTTP/1.1 400 Bad Request
Connection: close
Content-Length: 30
Content-Type: text/plain; charset=utf-8
Date: Thu, 27 Nov 2025 11:20:00 GMT
Server: uvicorn

Invalid HTTP request received.

-Subbu

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions