use of org.odk.collect.android.openrosa.CaseInsensitiveEmptyHeaders in project collect by opendatakit.
the class StubOpenRosaServer method executeHeadRequest.
@NonNull
@Override
public HttpHeadResult executeHeadRequest(@NonNull URI uri, @Nullable HttpCredentialsInterface credentials) throws Exception {
if (alwaysReturnError) {
return new HttpHeadResult(500, new CaseInsensitiveEmptyHeaders());
}
if (!uri.getHost().equals(HOST)) {
return new HttpHeadResult(410, new CaseInsensitiveEmptyHeaders());
} else if (credentialsIncorrect(credentials)) {
return new HttpHeadResult(401, new CaseInsensitiveEmptyHeaders());
} else if (uri.getPath().equals(OpenRosaConstants.SUBMISSION)) {
HashMap<String, String> headers = getStandardHeaders();
headers.put("x-openrosa-accept-content-length", "10485760");
return new HttpHeadResult(204, new MapHeaders(headers));
} else {
return new HttpHeadResult(404, new CaseInsensitiveEmptyHeaders());
}
}
use of org.odk.collect.android.openrosa.CaseInsensitiveEmptyHeaders in project collect by opendatakit.
the class OkHttpConnection method executeHeadRequest.
@NonNull
@Override
public HttpHeadResult executeHeadRequest(@NonNull URI uri, @Nullable HttpCredentialsInterface credentials) throws Exception {
OpenRosaServerClient httpClient = clientFactory.get(uri.getScheme(), userAgent, credentials);
Request request = new Request.Builder().url(uri.toURL()).head().build();
Timber.i("Issuing HEAD request to: %s", uri.toString());
Response response = httpClient.makeRequest(request, new Date());
int statusCode = response.code();
CaseInsensitiveHeaders responseHeaders = new CaseInsensitiveEmptyHeaders();
if (statusCode == HttpURLConnection.HTTP_NO_CONTENT) {
responseHeaders = new OkHttpCaseInsensitiveHeaders(response.headers());
}
discardEntityBytes(response);
return new HttpHeadResult(statusCode, responseHeaders);
}
Aggregations