Skip to content

std.http's one-line client calls lose the status: a 404 and a 500 both read "http error" #3147

Closed

Description

@nicolas-maman

http.get, get_with_timeout, post, put and delete turn any response that is not a 2xx into the error "http error" (and anything below 200 into "unexpected status"). The status is lost: a 404, a 500 and a 503 read the same, so a caller cannot tell "not found" from "the server is down" without moving to std.http.client. std/http/module.ae, get and its siblings.

Fix: the error names the status and its reason phrase, "HTTP 404 Not Found" ("HTTP 503 Service Unavailable"), for every one-line wrapper; the reference says so; tests check a 404 and a 500 from a local server. std.http.client stays the API that hands back the whole response.

Found on #3101's successor batch (#3105, writing the HTTP example).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions