Comments (8)
Wishful thinking, it seems. Will try for this week. Feel free to beat me to it.
from elli.
Thanks @jeffgrunewald
I opened a PR to have scheme
get set. I guess we can go with host
header for how to set the port and host.
from elli.
Thanks, Alan!
I asked him to open this here even though I think the underlying problem is likely in Erlang's packet parser since Elli just does:
parse_path({abs_path, FullPath}) ->
Parsed = case binary:split(FullPath, [<<"?">>]) of
[URL] -> {FullPath, split_path(URL), []};
[URL, Args] -> {FullPath, split_path(URL), split_args(Args)}
end,
{ok, {undefined, undefined, undefined}, Parsed};
parse_path({absoluteURI, Scheme, Host, Port, Path}) ->
setelement(2, parse_path({abs_path, Path}), {Scheme, Host, Port});
parse_path(_) ->
{error, unsupported_uri}.
So if Erlang packet parser is incorrectly returning {abs_path, Path}
instead of absoluteURI
this would happen and I think looks to be the only way it would happen.
But will need to verify this and could still be an Elli issue.
from elli.
Thanks! I can have a look sometime this week.
from elli.
For what it's worth, this appears to be related to the contents of the packet being passed back from the prim_inet
module not containing the scheme, host, or port information. I've tested this locally on MacOS running Big Sur as well as in a container (either Ubuntu or Debian) and a POST request to a local endpoint "http://localhost:4000/create"
in a test app results in a packet starting with <<"POST /create HTTP/1.1...">>
which decodes to:
{ok, {http_request, 'POST', {abs_path, "/create"}, {1, 1}...}}
if i manually modify the same packet to pre-pend the missing info to the path: <<"POST http://localhost:4000/create HTTP/1.1...">>
it decodes as I would expect to:
{ok, {http_request, 'POST', {absoluteURI, http, "localhost", 4000, "/create"}, {1, 1}...}}
I tried to trace this back to the source but best I can tell, it appears to be coming from the C message responses generated in the erts/emulator/drivers/common/inet_drv.c
but that's above my pay grade.
from elli.
Oh weird, thanks @jeffgrunewald
I wonder if we are supposed to just infer "localhost" if nothing else is there.
I was going to say the port could be taken from the socket itself but it should probably be the port in the URL and not the port being listened on, since those could technically be different.
from elli.
Where should we get the URL from if it's not able to be parsed from the packet? The host
entry in the headers list? Is that something we could reliably count on to be present in a request from any given client?
from elli.
FWIW, it looks like Cowboy attempts to get around this issue by primarily pulling the host from the clients’ host
header value and raising an exception if it’s not set, referring to the value being required by RFC7230 5.4: https://github.com/ninenines/cowboy/blob/2a082504996afccf78185182cd168123800bd4f0/src/cowboy_http.erl#L717
from elli.
Related Issues (20)
- Release request HOT 6
- Move tests to a CT suite
- Drop OTP =<21 support
- ellie (or erlang ssl) not sending intermediate certs - breaks the ssl chain. HOT 2
- Additional SSL options are being discarded ... HOT 1
- We get request_timeout for completed requests
- Can the server handle requests for the " transfer-Encoding: chunked" header? HOT 2
- Invalid spec for elli:stop/1 HOT 1
- undefined function erlang:get_stacktrace/0 HOT 1
- case-sensitive "keep-alive" causes errors HOT 1
- Some unhandled paths in case expressions
- HTTP2 support HOT 5
- Improved acceptor pool HOT 2
- failed TLS handshakes spawn new acceptors
- Release request HOT 13
- Cut 4.0 release
- Elli throws an exception when returning unexpected HTTP status codes HOT 1
- Exporting additional functions HOT 1
- Flaky SSL test returning `{badmatch, []}` periodically HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elli.