New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HttpUrl doesn't encode | in query parameters #1976

Closed
germanattanasio opened this Issue Nov 6, 2015 · 1 comment

Comments

3 participants
@germanattanasio

germanattanasio commented Nov 6, 2015

I'm not able to create a uri that has | in one of the query parameters.

HttpUrl.parse("http://do.not.use").newBuilder()
    .addQueryParameter("q", "one|two|tree")
    .build().uri();

Exception:

java.lang.IllegalStateException: not valid as a java.net.URI: http://do.not.use/?q=one|two|tree
    at com.squareup.okhttp.HttpUrl.uri(HttpUrl.java:336)

Should I encode the field and use addEncodedQueryParameter?

@JakeWharton

This comment has been minimized.

Show comment
Hide comment
@JakeWharton

JakeWharton Nov 7, 2015

Collaborator

Can you try with the code on master, or the 2.6.0-SNAPSHOT artifact?

On Sat, Nov 7, 2015 at 12:58 AM German Attanasio Ruiz <
notifications@github.com> wrote:

I'm not able to create a url that has | in one of the query parameters

HttpUrl.parse("http://do.not.use").newBuilder()
.addQueryParameter("q", "one|two|tree")
.build().uri();

Exception:

java.lang.IllegalStateException: not valid as a java.net.URI: http://do.not.use/?q=one|two|tree
at com.squareup.okhttp.HttpUrl.uri(HttpUrl.java:336)

Should I encode the field and use addEncodedQueryParameter?


Reply to this email directly or view it on GitHub
#1976.

Collaborator

JakeWharton commented Nov 7, 2015

Can you try with the code on master, or the 2.6.0-SNAPSHOT artifact?

On Sat, Nov 7, 2015 at 12:58 AM German Attanasio Ruiz <
notifications@github.com> wrote:

I'm not able to create a url that has | in one of the query parameters

HttpUrl.parse("http://do.not.use").newBuilder()
.addQueryParameter("q", "one|two|tree")
.build().uri();

Exception:

java.lang.IllegalStateException: not valid as a java.net.URI: http://do.not.use/?q=one|two|tree
at com.squareup.okhttp.HttpUrl.uri(HttpUrl.java:336)

Should I encode the field and use addEncodedQueryParameter?


Reply to this email directly or view it on GitHub
#1976.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment