use of org.openclinica.ns.response.v31.Response in project okhttp by square.
the class AsynchronousGet method run.
public void run() throws Exception {
Request request = new Request.Builder().url("http://publicobject.com/helloworld.txt").build();
client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
e.printStackTrace();
}
@Override
public void onResponse(Call call, Response response) throws IOException {
try (ResponseBody responseBody = response.body()) {
if (!response.isSuccessful())
throw new IOException("Unexpected code " + response);
Headers responseHeaders = response.headers();
for (int i = 0, size = responseHeaders.size(); i < size; i++) {
System.out.println(responseHeaders.name(i) + ": " + responseHeaders.value(i));
}
System.out.println(responseBody.string());
}
}
});
}
use of org.openclinica.ns.response.v31.Response in project okhttp by square.
the class CacheResponse method run.
public void run() throws Exception {
Request request = new Request.Builder().url("http://publicobject.com/helloworld.txt").build();
String response1Body;
try (Response response1 = client.newCall(request).execute()) {
if (!response1.isSuccessful())
throw new IOException("Unexpected code " + response1);
response1Body = response1.body().string();
System.out.println("Response 1 response: " + response1);
System.out.println("Response 1 cache response: " + response1.cacheResponse());
System.out.println("Response 1 network response: " + response1.networkResponse());
}
String response2Body;
try (Response response2 = client.newCall(request).execute()) {
if (!response2.isSuccessful())
throw new IOException("Unexpected code " + response2);
response2Body = response2.body().string();
System.out.println("Response 2 response: " + response2);
System.out.println("Response 2 cache response: " + response2.cacheResponse());
System.out.println("Response 2 network response: " + response2.networkResponse());
}
System.out.println("Response 2 equals Response 1? " + response1Body.equals(response2Body));
}
use of org.openclinica.ns.response.v31.Response in project keywhiz by square.
the class XsrfServletFilterIntegrationTest method rejectsForAdminUrlWithoutXsrf.
@Test
public void rejectsForAdminUrlWithoutXsrf() throws Exception {
noXsrfClient.newCall(buildLoginPost(DbSeedCommand.defaultUser, DbSeedCommand.defaultPassword)).execute();
Request request = new Request.Builder().url(testUrl("/admin/clients")).get().build();
Response response = noXsrfClient.newCall(request).execute();
assertThat(response.code()).isEqualTo(401);
}
use of org.openclinica.ns.response.v31.Response in project keywhiz by square.
the class XsrfServletFilterIntegrationTest method xsrfNotRequiredForLogout.
@Test
public void xsrfNotRequiredForLogout() throws Exception {
Request request = new Request.Builder().post(RequestBody.create(MediaType.parse("text/plain"), "")).url(testUrl("/admin/logout")).build();
Response response = client.newCall(request).execute();
assertThat(response.code()).isNotEqualTo(401);
}
use of org.openclinica.ns.response.v31.Response in project keywhiz by square.
the class XsrfServletFilterIntegrationTest method allowsForAdminUrlWithXsrf.
@Test
public void allowsForAdminUrlWithXsrf() throws Exception {
client.newCall(buildLoginPost(DbSeedCommand.defaultUser, DbSeedCommand.defaultPassword)).execute();
Request request = new Request.Builder().url(testUrl("/admin/clients")).get().build();
Response response = client.newCall(request).execute();
assertThat(response.code()).isNotEqualTo(401);
}
Aggregations