Search in sources :

Example 26 with HttpRequest

use of com.github.kevinsawicki.http.HttpRequest in project sonarqube by SonarSource.

the class WebTest method newRequest.

private HttpRequest newRequest(String url) {
    HttpRequest request = HttpRequest.get(url);
    request.followRedirects(false).acceptJson().acceptCharset(HttpRequest.CHARSET_UTF8);
    return request;
}
Also used : HttpRequest(com.github.kevinsawicki.http.HttpRequest)

Example 27 with HttpRequest

use of com.github.kevinsawicki.http.HttpRequest in project restfuse by eclipsesource.

the class InternalRequest method post.

public Response post() {
    HttpRequest request = HttpRequest.post(url);
    addContentType(request);
    addHeaders(request);
    addAuthentication(request);
    request.send(content);
    sendRequest(request);
    return new ResponseImpl(request);
}
Also used : HttpRequest(com.github.kevinsawicki.http.HttpRequest)

Example 28 with HttpRequest

use of com.github.kevinsawicki.http.HttpRequest in project restfuse by eclipsesource.

the class InternalRequest method head.

public Response head() {
    HttpRequest request = HttpRequest.head(url);
    addContentType(request);
    addHeaders(request);
    addAuthentication(request);
    sendRequest(request);
    return new ResponseImpl(request);
}
Also used : HttpRequest(com.github.kevinsawicki.http.HttpRequest)

Example 29 with HttpRequest

use of com.github.kevinsawicki.http.HttpRequest in project restfuse by eclipsesource.

the class InternalRequest method get.

public Response get() {
    HttpRequest request = HttpRequest.get(url);
    addContentType(request);
    addHeaders(request);
    addAuthentication(request);
    sendRequest(request);
    return new ResponseImpl(request);
}
Also used : HttpRequest(com.github.kevinsawicki.http.HttpRequest)

Example 30 with HttpRequest

use of com.github.kevinsawicki.http.HttpRequest in project ninja by ninjaframework.

the class NinjaJettyTest method sessionsAreNotSharedOnSingleResultInstances.

@Test
public void sessionsAreNotSharedOnSingleResultInstances() throws Exception {
    // this test is not really specific to jetty, but its easier to test here
    NinjaJetty standalone = new NinjaJetty().externalConfigurationPath("conf/jetty.com.session.conf").port(RANDOM_PORT);
    try {
        standalone.start();
        // establish session with a set-cookie header
        HttpRequest client0 = HttpRequest.get(standalone.getBaseUrls().get(0) + "/getOrCreateSession");
        assertThat(client0.code(), is(200));
        assertThat(client0.header("Set-Cookie"), is(not(nullValue())));
        // call redirect so its session is processed first time (triggers bug for issue #450)
        HttpRequest client1 = HttpRequest.get(standalone.getBaseUrls().get(0) + "/badRoute").header("Cookie", client0.header("Set-Cookie")).followRedirects(false);
        assertThat(client1.code(), is(303));
        assertThat(client1.header("Set-Cookie"), is(not(nullValue())));
        // call redirect with a mock new browser (no cookie header) -- we
        // should not get a session value back
        HttpRequest client2 = HttpRequest.get(standalone.getBaseUrls().get(0) + "/badRoute").followRedirects(false);
        assertThat(client2.code(), is(303));
        // if cookie is NOT null then someone elses cookie (from the previous
        // request above) got assigned to us!
        assertThat(client2.header("Set-Cookie"), is(nullValue()));
    } finally {
        standalone.shutdown();
    }
}
Also used : HttpRequest(com.github.kevinsawicki.http.HttpRequest) Test(org.junit.Test)

Aggregations

HttpRequest (com.github.kevinsawicki.http.HttpRequest)86 HttpRequestException (com.github.kevinsawicki.http.HttpRequest.HttpRequestException)29 IOException (java.io.IOException)25 JSONObject (org.json.JSONObject)19 UnsupportedEncodingException (java.io.UnsupportedEncodingException)13 File (java.io.File)8 TimerTask (java.util.TimerTask)8 AtomicLong (java.util.concurrent.atomic.AtomicLong)8 Pair (android.util.Pair)6 URL (java.net.URL)5 JSONException (org.json.JSONException)5 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)4 JSONObject (com.alibaba.fastjson.JSONObject)4 ZipFile (net.lingala.zip4j.ZipFile)4 SSLHandshakeException (javax.net.ssl.SSLHandshakeException)3 IPEntity (com.example.li.springboot_crawler_demo.utils.img.entity.IPEntity)2 HttpURLConnection (java.net.HttpURLConnection)2 MalformedURLException (java.net.MalformedURLException)2 Matcher (java.util.regex.Matcher)2 JSONArray (org.json.JSONArray)2