Skip to content

Tesla does not properly encode URLs #798

@feld

Description

@feld

I believe this is a bug with Tesla as I would expect the HTTP client/wrapper to handle this automatically.

Take a simple URL with a space in it as an example: http://127.0.0.1:8080/foo/file 1.txt

Let's capture the request with netcat or whatever you prefer:

Tesla.get("http://127.0.0.1:8080/foo/file 1.txt")

> nc -l 127.0.0.1 8080
GET /foo/file 1.txt HTTP/1.1
content-length: 0
host: 127.0.0.1:8080

The space is still there!

Now let's try with curl

> curl "http://127.0.0.1:8080/foo/file 1.txt"
curl: (3) URL rejected: Malformed input to a URL function

Aha, it refused the request. Let's fix it.

curl "http://127.0.0.1:8080/foo/file%201.txt"

GET /foo/file%201.txt HTTP/1.1
Host: 127.0.0.1:8080
User-Agent: curl/8.7.1
Accept: */*

The path is properly encoded; curl wouldn't even attempt the invalid request.

I have tried with Hackney, Gun, and Finch. The result is the same.

Is this an oversight, or does Tesla expect to be provided URLs that are already properly encoded?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions