String redirectedReqString = firstPutReq.getResponseHeader(LOCATION).getValue(); PutMethod redirectedReq = new PutMethod(redirectedReqString); File localFile = new File(localFilePath);
throws RedirectException { Header locationHeader = method.getResponseHeader("location"); if (locationHeader == null) {
@Override public String getResponseHeader(final String headerName) { Header responseHeader = methodResponse.getResponseHeader(headerName); return responseHeader == null ? null : responseHeader.getValue(); }
@Override public String getResponseHeader(final String headerName) { Header responseHeader = methodResponse.getResponseHeader(headerName); return responseHeader == null ? null : responseHeader.getValue(); }
@Override public InputStream getResponseStream() throws IOException { if (responseBodyAsStream == null) { responseBodyAsStream = methodResponse.getResponseBodyAsStream(); // commons httpclient does not handle gzip encoding automatically, we have to check // ourselves: https://issues.apache.org/jira/browse/HTTPCLIENT-816 Header header = methodResponse.getResponseHeader("Content-Encoding"); if (header != null && "gzip".equals(header.getValue())) { responseBodyAsStream = new GZIPInputStream(responseBodyAsStream); } } return responseBodyAsStream; }
Header h = get.getResponseHeader("Refresh"); if (h != null) { String s = h.getValue();
@Override public HttpVersion getProtocol() { org.apache.commons.httpclient.HttpVersion version = httpMethod .getParams().getVersion(); if (version == null) { return null; } Header connection = httpMethod.getResponseHeader("Connection"); if (protocol == null) { protocol = new HttpVersion("HTTP", version.getMajor(), version.getMinor(), connection != null && KEEP_ALIVE.equalsIgnoreCase(connection .getValue())); } return protocol; }
@Override public String getResponseHeader(final String headerName) { Header responseHeader = methodResponse.getResponseHeader(headerName); return responseHeader == null ? null : responseHeader.getValue(); }
public String getHeader(String name) { Header header = method.getResponseHeader(name); return (header != null) ? header.getValue() : null; }
@Override public String getResponseHeader(final String headerName) { Header responseHeader = methodResponse.getResponseHeader(headerName); return responseHeader == null ? null : responseHeader.getValue(); }
/** * Return the value of the named HTTP header */ public String getHeader(String header) { Header h = method.getResponseHeader(header); return h != null ? h.getValue() : null; }
public String getHeader(String name) { Header header = method.getResponseHeader(name); return (header != null) ? header.getValue() : null; }
private boolean isZipContent(HttpMethod httpMethod) { Header responseHeader = httpMethod.getResponseHeader(Constants.CONTENT_ENCODING); if (null == responseHeader) return false; String acceptEncoding = responseHeader.getValue(); return acceptEncoding.toLowerCase().indexOf("gzip") > -1; }
private static int getVersion(HttpMethod httpMethod) throws DateParseException { int version = 0; Header header = httpMethod.getResponseHeader(LAST_MODIFIED_HEADER); if (header != null) { String lastModified = header.getValue(); Date lastModifiedDate = DateUtil.parseDate(lastModified); SimpleDateFormat sdf = new SimpleDateFormat(DATE_PATTERN); version = Integer.parseInt(sdf.format(lastModifiedDate)); } return version; }
/** Returns the value of the specified named response header field. */ public String getResponseHeader(String header) throws HttpClientException { if (httpMethod == null) { throw new HttpClientException("Connection not yet established"); } return httpMethod.getResponseHeader(header).getValue(); }
private boolean isRedirect(HttpMethod httpMethod) { int code = httpMethod.getStatusCode(); return (code == 301 || code == 302 || code == 303 || code == 307) && httpMethod.getResponseHeader("location") != null; }
protected static InputStream getInputStream(HttpMethod method) throws IOException { InputStream is = method.getResponseBodyAsStream(); Header h = method.getResponseHeader("Content-Encoding"); if (h != null && h.getValue().equals("gzip")) { is = new GZIPInputStream(is); } return is; }
private static int getVersion(HttpMethod httpMethod) throws DateParseException { int version = 0; Header header = httpMethod.getResponseHeader(LAST_MODIFIED_HEADER); if (header != null) { String lastModified = header.getValue(); Date lastModifiedDate = DateUtil.parseDate(lastModified); SimpleDateFormat sdf = new SimpleDateFormat(DATE_PATTERN); version = Integer.parseInt(sdf.format(lastModifiedDate)); } return version; }
protected String getHeader(String header) throws URISyntaxException, HttpException, IOException { HttpMethod head = new HeadMethod(url); int code = http.executeMethod(head); if(code != 200) { throw new IOException("Unable to retrieve from " + url); } Header theHeader = head.getResponseHeader(header); if(theHeader == null) { throw new IOException("No " + header + " header for " + url); } String val = theHeader.getValue(); return val; }
private static void assertDate(HttpMethod method, String header) throws Exception { Header dateHeader = method.getResponseHeader(header); assertNotNull(dateHeader); Date parsedDate = dateFormat.parse(dateHeader.getValue()); assertTrue("Parsed date is before this code was written: " + parsedDate, parsedDate.after(new GregorianCalendar(2013, 1, 1).getTime())); }