use of okhttp3.HttpUrl in project vimeo-networking-java by vimeo.
the class BaseUrlInterceptorTest method test_excludePathsForBaseUrl_UnsanitizedPaths_SuccessfullyIntercepts.
@Test
public void test_excludePathsForBaseUrl_UnsanitizedPaths_SuccessfullyIntercepts() throws Exception {
HttpUrl httpUrl = HttpUrl.parse("http://localhost");
mBaseUrlInterceptor.excludePathsForBaseUrl(httpUrl, "me", "you");
mBaseUrlInterceptor.intercept(createVerificationChain(createTestUrlForPath("/me"), createTestUrlForPath(null)));
mBaseUrlInterceptor.intercept(createVerificationChain(createTestUrlForPath("/you"), createTestUrlForPath(null)));
mBaseUrlInterceptor.intercept(createVerificationChain(createTestUrlForPath("/them"), httpUrl));
}
use of okhttp3.HttpUrl in project runelite by runelite.
the class XteaClient method submit.
public Response submit(int revision, int region, int[] keys) throws IOException {
XteaRequest xteaRequest = new XteaRequest();
xteaRequest.setRevision(revision);
XteaKey xteaKey = new XteaKey();
xteaKey.setRegion(region);
xteaKey.setKeys(keys);
xteaRequest.addKey(xteaKey);
String json = RuneLiteAPI.GSON.toJson(xteaRequest);
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder().addPathSegment("xtea").build();
logger.debug("Built URI: {}", url);
Request request = new Request.Builder().post(RequestBody.create(JSON, json)).url(url).build();
return RuneLiteAPI.CLIENT.newCall(request).execute();
}
use of okhttp3.HttpUrl in project runelite by runelite.
the class XteaClient method get.
public List<XteaKey> get() throws IOException {
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder().addPathSegment("xtea").build();
Request request = new Request.Builder().url(url).build();
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) {
InputStream in = response.body().byteStream();
// CHECKSTYLE:OFF
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), new TypeToken<List<XteaKey>>() {
}.getType());
// CHECKSTYLE:ON
} catch (JsonParseException ex) {
throw new IOException(ex);
}
}
use of okhttp3.HttpUrl in project runelite by runelite.
the class ConfigClient method unset.
public void unset(String key) throws IOException {
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder().addPathSegment("config").addPathSegment(key).build();
logger.debug("Built URI: {}", url);
Request request = new Request.Builder().delete().header(RuneLiteAPI.RUNELITE_AUTH, uuid.toString()).url(url).build();
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) {
logger.debug("Unset configuration value '{}'", key);
}
}
use of okhttp3.HttpUrl in project runelite by runelite.
the class ConfigClient method set.
public void set(String key, String value) throws IOException {
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder().addPathSegment("config").addPathSegment(key).build();
logger.debug("Built URI: {}", url);
Request request = new Request.Builder().put(RequestBody.create(TEXT_PLAIN, value)).header(RuneLiteAPI.RUNELITE_AUTH, uuid.toString()).url(url).build();
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) {
logger.debug("Set configuration value '{}' to '{}'", key, value);
}
}
Aggregations