public void setIfModifiedSince(long modifiedSince) { String ifModifiedSince = formatDate(modifiedSince); setHeader(IF_MODIFIED_SINCE, ifModifiedSince); }
public void setIfNoneMatch(String eTag) { setHeader(IF_NONE_MATCH, eTag); } }
private Get get(String url) { Get get = new Get(url); get.setUserAgent(USER_AGENT); return get; }
private void setAuthentication(Credentials credentials) { URI uri = method.getURI(); setAuthentication(credentials.getUserName(), credentials.getPassword(), uri); }
public boolean isForbidden() throws IOException { return getStatusCode() == SC_FORBIDDEN; }
public void setRange(long startIndex, Long endIndex) { // avoid GZIP'ed range disableContentCompression(); // Apache accepts just bytes=1234-1235 while the spec says bytes 1234-1235/1236 setHeader(RANGE, "bytes=" + startIndex + "-" + (endIndex != null ? endIndex : "")); } }
HttpRequest(HttpRequestBase method, Credentials credentials) { this(method); if (credentials != null) setAuthentication(credentials); }
public String getETag() throws IOException { return getHeader(ETAG); }
public void setAccept(String accept) { setHeader(ACCEPT, accept); } }
private HttpEntityEnclosingRequestBase getHttpEntityEnclosingRequestBase() { return (HttpEntityEnclosingRequestBase) getMethod(); }
public String getLocation() throws IOException { return getHeader(LOCATION); }
protected Credentials getCredentials() { return new SimpleCredentials(dataSourcesUserName, dataSourcesPassword); }
public boolean isPreconditionFailed() throws IOException { return getStatusCode() == SC_PRECONDITION_FAILED; } }
public boolean isOk() throws IOException { return getStatusCode() == SC_OK; }
public boolean isUnAuthorized() throws IOException { return getStatusCode() == SC_UNAUTHORIZED; }
public boolean isNotFound() throws IOException { return getStatusCode() == SC_NOT_FOUND; }
public boolean isSuccessful() throws IOException { return getStatusCode() >= SC_OK && getStatusCode() < SC_MULTIPLE_CHOICES; }
public boolean isBadRequest() throws IOException { return getStatusCode() == SC_BAD_REQUEST; }
public boolean isNotModified() throws IOException { return getStatusCode() == SC_NOT_MODIFIED; }
public boolean isPartialContent() throws IOException { return getStatusCode() == SC_PARTIAL_CONTENT; }