Class HttpUrl.Builder

  • Enclosing class:
    HttpUrl

    public static class HttpUrl.Builder
    extends Object
    Builder to construct new HttpUrl.
    • Constructor Detail

      • Builder

        public Builder​(URI uri)
        Constructor.
        Parameters:
        uri - Base URI to be augmented
    • Method Detail

      • addQueryParameter

        public HttpUrl.Builder addQueryParameter​(String key,
                                                 String value)
        Adds query param to constructed URL.
        Parameters:
        key - Query param key
        value - Query param valu
        Returns:
        builder
      • addPathSegment

        public HttpUrl.Builder addPathSegment​(String segment)
        Adds path segment to constructed URL. NOTE: This method doesn't allow slashes or double periods to prevent path traversal. Adjust and/or add a method to add multiple path segments at once if those are needed.
        Parameters:
        segment - URL segment to add.
        Returns:
        builder
      • build

        public HttpUrl build()
        Builds the HttpUrl with constructed URL.
        Returns:
        new HttpUrl.