CrowdHailer / raxx

Interface for HTTP webservers, frameworks and clients
https://hexdocs.pm/raxx
Apache License 2.0
400 stars 29 forks source link

Incorrect parsing of request when path looks like an absolute url #175

Closed CrowdHailer closed 5 years ago

CrowdHailer commented 5 years ago

This is an example

iex> Raxx.HTTP1.parse_request("GET //foo/bar HTTP/1.1\r\nhost: example.com\r\n\r\n", scheme: :http)
{:ok,
 {%Raxx.Request{
    authority: "example.com",
    body: false,
    headers: [],
    method: :GET,
    path: ["bar"],
    query: nil,
    raw_path: "/bar",
    scheme: :http
  }, nil, {:complete, ""}, ""}}

Question is this incorrect? A url beginning with a double slash is considered to be followed by the host then path. e.g.

iex(4)> URI.parse("//foo/bar")
%URI{
  authority: "foo",
  fragment: nil,
  host: "foo",
  path: "/bar",
  port: nil,
  query: nil,
  scheme: nil,
  userinfo: nil
}
CrowdHailer commented 5 years ago

Fixed by https://github.com/CrowdHailer/Ace/commit/02da0b177fe213cc8abd87dd362c1cbfcc97acab