Example usage for com.squareup.okhttp Request urlString

List of usage examples for com.squareup.okhttp Request urlString

Introduction

In this page you can find the example usage for com.squareup.okhttp Request urlString.

Prototype

public String urlString() 

Source Link

Usage

From source file:com.xing.api.CallSpecTest.java

License:Apache License

@Test
public void builderAttachesQueryParamsAsVarList() throws Exception {
    CallSpec.Builder builder = builder(HttpMethod.GET, "", false).responseAs(Object.class).queryParam("q",
            "testL", "testL");
    // Build the CallSpec so that we don't test this behaviour twice.
    builder.build().queryParam("w", "testL", "testL");

    Request request = builder.request();
    assertThat(request.method()).isEqualTo(HttpMethod.GET.method());
    assertThat(request.urlString()).isEqualTo(httpUrl + "?q=testL%2C%20testL&w=testL%2C%20testL");
    assertThat(request.body()).isNull();
}

From source file:com.xing.api.CallSpecTest.java

License:Apache License

@Test
public void builderAttachesQueryParamsAsList() throws Exception {
    List<String> query = new ArrayList<>(2);
    query.add("testL");
    query.add("testL");

    CallSpec.Builder builder = builder(HttpMethod.GET, "", false).responseAs(Object.class).queryParam("q",
            query);//from   w w  w .ja  v a2s . c o m
    // Build the CallSpec so that we don't test this behaviour twice.
    builder.build().queryParam("w", query);

    Request request = builder.request();
    assertThat(request.method()).isEqualTo(HttpMethod.GET.method());
    assertThat(request.urlString()).isEqualTo(httpUrl + "?q=testL%2C%20testL&w=testL%2C%20testL");
    assertThat(request.body()).isNull();
}

From source file:io.appium.uiautomator2.unittest.test.internal.Client.java

License:Apache License

private static Response execute(final Request request) {
    try {//from  www. j  a  v a2s  .co  m
        return new Response(HTTP_CLIENT.newCall(request).execute());
    } catch (IOException e) {
        throw new UiAutomator2Exception(request.method() + " \"" + request.urlString() + "\" " + "failed. ", e);
    }
}

From source file:io.fabric8.docker.client.impl.OperationSupport.java

License:Apache License

DockerClientException requestFailure(Request request, Response response) {
    StringBuilder sb = new StringBuilder();
    sb.append("Failure executing: ").append(request.method()).append(" at: ").append(request.urlString())
            .append(".").append(" Status:").append(response.code()).append(".").append(" Message: ")
            .append(response.message()).append(".");
    try {//from  www .  ja  va 2  s  . c  om
        String body = response.body().string();
        sb.append(" Body: ").append(body);
    } catch (Throwable t) {
        sb.append(" Body: <unreadable>");
    }
    return new DockerClientException(sb.toString(), response.code());
}

From source file:io.fabric8.docker.client.impl.OperationSupport.java

License:Apache License

DockerClientException requestException(Request request, Exception e) {
    StringBuilder sb = new StringBuilder();
    sb.append("Error executing: ").append(request.method()).append(" at: ").append(request.urlString())
            .append(". Cause: ").append(e.getMessage());

    return new DockerClientException(sb.toString(), e);
}

From source file:io.fabric8.kubernetes.client.dsl.base.OperationSupport.java

License:Apache License

KubernetesClientException requestFailure(Request request, Status status) {
    StringBuilder sb = new StringBuilder();
    sb.append("Failure executing: ").append(request.method()).append(" at: ").append(request.urlString())
            .append(".");

    if (status.getMessage() != null && !status.getMessage().isEmpty()) {
        sb.append(" Message: ").append(status.getMessage()).append(".");
    }/* w  w  w  . j  a  v  a 2  s . c  o  m*/

    if (status != null && !status.getAdditionalProperties().containsKey(CLIENT_STATUS_FLAG)) {
        sb.append(" Received status: ").append(status).append(".");
    }

    return new KubernetesClientException(sb.toString(), status.getCode(), status);
}

From source file:io.fabric8.kubernetes.client.dsl.base.OperationSupport.java

License:Apache License

KubernetesClientException requestException(Request request, Exception e) {
    StringBuilder sb = new StringBuilder();
    sb.append("Error executing: ").append(request.method()).append(" at: ").append(request.urlString())
            .append(". Cause: ").append(e.getMessage());

    return new KubernetesClientException(sb.toString(), e);
}

From source file:io.jawg.osmcontributor.rest.utils.AuthenticationRequestInterceptor.java

License:Open Source License

@Override
public Request authenticate(Proxy proxy, Response response) throws IOException {
    Map<String, String> oAuthParams = loginPreferences.retrieveOAuthParams();

    if (oAuthParams != null) {
        Request originalRequest = response.request();
        String requestUrl = originalRequest.urlString();

        OAuthRequest oAuthRequest = new OAuthRequest(oAuthParams.get(CONSUMER_PARAM),
                oAuthParams.get(CONSUMER_SECRET_PARAM));
        oAuthRequest//from  w w w.j a  v a2s  .  c  o m
                .initParam(OAuthParams.getOAuthParams().put(TOKEN_PARAM, oAuthParams.get(TOKEN_PARAM)).toMap());
        oAuthRequest.setOAuthToken(oAuthParams.get(TOKEN_PARAM));
        oAuthRequest.setOAuthTokenSecret(oAuthParams.get(TOKEN_SECRET_PARAM));
        oAuthRequest.setRequestUrl(requestUrl);
        oAuthRequest.signRequest(Verb.valueOf(originalRequest.method()));
        oAuthRequest.encodeParams();

        Request.Builder finalRequest = originalRequest.newBuilder().header("Accept", "text/xml")
                .header("Authorization", oAuthRequest.getOAuthHeader())
                .method(originalRequest.method(), originalRequest.body());
        return finalRequest.build();
    } else {
        // create Base64 encoded string
        String authorization = "Basic " + Base64.encodeToString(
                (loginPreferences.retrieveLogin() + ":" + loginPreferences.retrievePassword()).getBytes(),
                Base64.NO_WRAP);
        return response.request().newBuilder().header("Authorization", authorization)
                .header("Accept", "text/xml").build();
    }
}

From source file:me.lock8.Mzigo.java

License:Apache License

public void journalCall(Request request, Call call, Callback callback) {
    ongoingCalls.put(request.urlString(), call);
    responseListenerForCallback(callback).registerTag(request.tag());
}

From source file:me.lock8.Mzigo.java

License:Apache License

public void unJournalCall(Request request, Callback callback) {
    ongoingCalls.remove(request.urlString());
    responseListenerForCallback(callback).unregisterTag(request.tag());
}