From inside a worker server, the only external hostname is "httpl://host.page"
To reach anything, the worker proxies through the hostpage.
"httpl://host.page/http%3A%2F%2Fexplorer%2F"
(This is why I want the percent-encoding rendering more nicely, but that's another topic.)
When links come back in the Link header, Local.js adds some extracted data.
From
Link: <http://foobar.com/foo>; rel="service"; title="foo"
to
Link: <http://foobar.com/foo>; host_domain="foobar.com"; rel="service"; title="foo"
If it's a global URI ([email protected]!foo.com!123) it also extracts and adds host_user, host_network, host_app, and host_sid. These are the host_* attrs.
They are helpful for navigating the links
agent.follow({ rel: 'gwr.io/chat', host_user: 'pfraze' }) // go to pfraze's chat
But it needs to be extracted from the URI so that the host_* attrs can always be trusted. Otherwise, rando server could do:
Link: <http://foo.com>; host_domain="lies.com"; title="This is totally lies.com not foo.com"
This is how the response from a proxy gets transformed:
From
Link: <httpl://host.page/http%3A%2F%2Fexplorer%2F>; rel="service"; title="Explorer"
to
Link: <httpl://host.page/http%3A%2F%2Fexplorer%2F>; host_domain="host.page"; rel="service"; title="Explorer"
Oh noes, host_domain will always be "host.page". Not very useful that way -- I need to reason about the endpoint, not the proxy.
Because Localjs overwrites all the host_
attributes, the proxy can't override the host_
values.
From
Link: <httpl://host.page/http%3A%2F%2Fexplorer%2F>; rel="service"; title="Explorer"
to
Link: <httpl://host.page/http%3A%2F%2Fexplorer%2F>; host_domain="host.page"; up1_domain="explorer"; rel="service"; title="Explorer"
Above, that would be up1_domain
. It's numbered to account for the possibility of multiple proxies.
Let the host page proxy override the host_
attributes. This can only work if the proxy is known to be trusted.
This means that all proxy URIs need to follow a format that local can predict and pick apart.
Instead, preserve the responses and let the client construct proxied URIs using the Via header
Via: HTTPL/0.1 host.page
Link: <httpl://explorer/>; rel="self service", </foo>; rel="item"; id="foo"
becomes
Link: <httpl://host.page/httpl://explorer/>; host_domain="explorer"; rel="self service", <httpl://host.page/httpl://explorer/foo>; host_domain="explorer"; rel="item"; id="foo"
Cons:
- Can't distinguish between links which should or should not be proxied
- Enforces only one kind of proxy URI (where the path is the subsequent request)