Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add testcase for absolute URI #42 #44

Merged

Conversation

samsondav
Copy link
Contributor

No description provided.

test "handles absoluteURI", %{port: port} do
request = """
GET http://www.raxx.com/ HTTP/1.1
"""
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make sure this is a valid request there needs to be a full empty line after headers.

@@ -49,6 +49,15 @@ defmodule Ace.HTTP.RequestTest do
assert upload.type == "text/plain"
end

test "handles absoluteURI", %{port: port} do
request = """
GET http://www.raxx.com/ HTTP/1.1
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure but I suspect that even though this is using an absolute url in the start-line there is still a requirement for a Host header.

I started reading the spec but found it to be inconclusive https://tools.ietf.org/html/rfc7230#section-5.3.2

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right.A client MUST send a Host header field in all HTTP/1.1 request messages.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally:

A server MUST respond with a 400 (Bad Request) status code to any
   HTTP/1.1 request message that lacks a Host header field and to any
   request message that contains more than one Host header field or a
   Host header field with an invalid field-value.

@CrowdHailer
Copy link
Owner

Good point on the 400 for missing host header, if that does not already happen it should probably be another issue.

Want to have a crack at the implementation, I'm a bit busy so will probably be able to take a look more on the weekend. Happy to keep offering comments before then if you want.

{:ok, {:http_request, method, http_uri, _version}, rest} ->
path_string =
case http_uri do
{:abs_path, path_string} -> path_string
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you start a newline after every ->

path_string =
case http_uri do
{:abs_path, path_string} -> path_string
{:absoluteURI, _scheme, _host, _port, path_string} -> path_string # Throw away the rest of the absolute URI since we are not proxying
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put comment on line above as it is too long otherwise

@CrowdHailer CrowdHailer mentioned this pull request Aug 8, 2017
@CrowdHailer
Copy link
Owner

There is definitely more to this issue as a absoluteURI should be received only if we are proxying yet you note that we are not proxying. 🤔

@CrowdHailer
Copy link
Owner

To finish this PR can you bump the patch number on the mix file version
also no harm in updating it's dependency in ace to the latest 0.9 one, that change should be reflected in the logfile as well

@samsondav
Copy link
Contributor Author

@CrowdHailer made those changes, seems like Ace.HTTP doesn't have a CHANGELOG though?

@CrowdHailer
Copy link
Owner

@samphilipd unless you want to make a changelog it's probably staying that way for the moment. I think eventually I want to bundle AceHTTP and AceHTTP2 together and that will happily mean one changlog

@CrowdHailer CrowdHailer merged commit 04f6429 into CrowdHailer:0.9.x Aug 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants