Support for arbitrary url schemes?
See original GitHub issueI’m trying to use OkHttp to connect to the Docker remote api. Since they support several ways of connecting to their daemon, including unix sockets, they use several url schemes. They still use HTTP, though, but connect via TCP, Unix Domain Sockets or even Names Pipes.
When trying to use a url like unix:///var/run/docker.sock
, OkHttp refuses to use that url, because it enforces us to use either http
or https
.
I know that OkHttp wasn’t supposed to handle such hacky ways of connecting via Unix Sockets, which is why I won’t ask for a solution directly in OkHttp itself. My concern is more about the strict parser to only accept http(s). Would you be willing to add an option to the url parser to accept arbitrary schemes? I guess it would even be enough to support some kind of overrides. For me it would be enough to tell OkHttp that I know what I’m doing.
For the bigger picture: given the url parser to accept arbitrary schemes, I still need to provide my own SocketFactory (to connect via unix or npipe). I assume that’s possible? Essentially I only want to use OkHttp to leverage the HTTP stuff, but also be able to connect via different transport mechanisms. If you now tell me that I’m crazy and that you don’t want OkHttp to also go crazy, please do so 😃
If you think opening OkHttp to support different connection strategies is a good thing, I’d be happy to provide pull requests, with the first one obviously making the url parser less strict.
Issue Analytics
- State:
- Created 7 years ago
- Comments:13 (4 by maintainers)
Top GitHub Comments
Here’s a class that might help: https://gist.github.com/swankjesse/7ffbc7f7ec9d6fc9deb026d8726eae84
Use it like this:
You’ll still need to figure out what else goes inside the
connect()
method. All this does is retrieve the path through a backchannel.done - looks like I need to browse even more of your api…