void KURL::removePort()
{
    if (hasPort()) {
        String urlWithoutPort = m_url.string().left(hostEnd()) + m_url.string().substring(pathStart());
        m_url.setUtf8(urlWithoutPort.utf8());
    }
}
Exemple #2
0
void KURL::removePort() {
  if (!hasPort())
    return;
  url::Replacements<char> replacements;
  replacements.ClearPort();
  replaceComponents(replacements);
}
Exemple #3
0
void URL::updatePort(std::uint16_t port)
{    
    if (!hasPort())
        throw std::runtime_error("Cannot update invalid URL");        

    std::string tmp(str());
    util::replaceInPlace(tmp, 
        util::itostr<std::uint16_t>(this->port()), 
        util::itostr<std::uint16_t>(port));
    parse(tmp);
}
Exemple #4
0
std::uint16_t URL::port() const
{
    if (hasPort())
        return _parser.port;
    std::string sc = scheme();
    if (sc == "http")
        return 80;
    else if (sc == "https")
        return 443;
    return 0;
}
Exemple #5
0
std::string ZDvidTarget::getAddressWithPort() const
{
  std::string address;

  if (!getAddress().empty()) {
    address = getAddress();
    if (hasPort()) {
      address += ":" + ZString::num2str(getPort());
    }
  }

  return address;
}
Exemple #6
0
std::string URL::authority() const
{
    std::string res;    
    if (hasUserInfo()) {
        res.append(userInfo());
        res.append("@");
    }
    res.append(host());
    if (hasPort()) {
        res.append(":");
        res.append(util::itostr<std::uint16_t>(port()));
    }
    return res;
}
Exemple #7
0
void ParsedURL::removePort()
{
    if (!hasPort())
        return;

    // 1) Remove the port from the spec, including the delimiter.
    String newSpec;
    int beginning = m_segments.port.begin() - 1;
    unsigned length = m_segments.port.length() + 1;

    String newSpecString = m_spec.string();
    newSpecString.remove(beginning, length);
    m_spec = URLString(newSpecString);

    // 2) Update the components positions.
    m_segments.port.reset();
    m_segments.moveFromComponentBy(URLSegments::Path, -length);
}
Exemple #8
0
 int HostAndPort::port() const {
     if (hasPort())
         return _port;
     return ServerGlobalParams::DefaultDBPort;
 }
::std::string HostAndPort::toString() const {
    return (hasPort() ? _host + DELIM + ::std::to_string(static_cast<long long unsigned int>(*_port))
                      : _host + DELIM);
}