Skip to content

URL validation makes it impossible to implement unix domain socket transport #1119

@algesten

Description

@algesten

The URL validation in ureq3 is too strict. Even if ureq3 doesn't claim to support unix domain sockets itself, it's not possible to implement a transport that could do it.

This is stricter than what ureq3 is intended to be.

I just spent a day trying to get this work, and couldn't. There's no way I could find to avoid the check in default_port:

ureq/src/util.rs

Lines 49 to 59 in 1ce334d

fn default_port(&self) -> Option<u16> {
if *self == Scheme::HTTPS {
Some(443)
} else if *self == Scheme::HTTP {
Some(80)
} else if let Ok(proxy) = ProxyProtocol::try_from(self.as_str()) {
Some(proxy.default_port())
} else {
debug!("Unknown scheme: {}", self);
None
}

Which always results in a parsing error:

ureq/src/util.rs

Lines 319 to 321 in 1ce334d

scheme
.default_port()
.ok_or_else(|| Error::BadUri(format!("unknown scheme: {}", scheme)))?;

You could just pass a completely fake uri to the agent, I guess, but that's pretty ugly. I think this issue should be reopened.

Originally posted by @colinmarc in #538

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions