public Header getLastHeader( String arg0 ) { return responseBase.getLastHeader( arg0 ); }
/** * This method populates <code>curi</code> with response status and * content type. * * @param curi * CrawlURI to populate. * @param response * Method to get response status and headers from. */ protected void addResponseContent(HttpResponse response, CrawlURI curi) { curi.setFetchStatus(response.getStatusLine().getStatusCode()); Header ct = response.getLastHeader("content-type"); curi.setContentType(ct == null ? null : ct.getValue()); for (Header h: response.getAllHeaders()) { curi.putHttpResponseHeader(h.getName(), h.getValue()); } }
Header locationHeader = httpResponse.getLastHeader("Location");
@Test public void shouldSupportGetLastHeader() throws Exception { HttpResponse resp = new TestHttpResponse(304, "REDIRECTED", new BasicHeader("Location", "http://bar.com"), new BasicHeader("Location", "http://zombo.com")); assertThat(resp.getLastHeader("None")).isNull(); for (String l : new String[] { "location", "Location" }) { assertThat(resp.getLastHeader(l).getValue()).isEqualTo("http://zombo.com"); } }
public Header getLastHeader( String arg0 ) { return responseBase.getLastHeader( arg0 ); }
Header h = response.getLastHeader("content-length"); if (h != null && h.getValue().trim().length()>0) { contentLength = Long.parseLong(h.getValue());
HttpClient client = new DefaultHttpClient(); HttpParams params = client.getParams(); HttpClientParams.setRedirecting(params, false); HttpGet method = new HttpGet("http://forecast.weather.gov/zipcity.php?inputstring=90210"); HttpResponse resp = client.execute(method); String location = resp.getLastHeader("Location").getValue();
@Override public Header getLastHeader(final String name) { return original.getLastHeader(name); }
public Header getLastHeader( String arg0 ) { return responseBase.getLastHeader( arg0 ); }
public String handleResponse(HttpResponse httpResponse) throws ClientProtocolException, IOException { Header header = httpResponse.getLastHeader("Location"); // System.out.println("header=" + header); return (header != null) ? header.getValue().trim() : null; } });
public URI handleResponse(HttpResponse response) throws IOException { URI uri = getContentId(localContext); Header location = response .getLastHeader("Content-Location"); if (location == null) { return uri; } else { return uri.resolve(location.getValue()); } } }, localContext);
public URI handleResponse(HttpResponse response) throws IOException { URI uri = getContentId(localContext); Header location = response .getLastHeader("Content-Location"); if (location == null) { return uri; } else { return uri.resolve(location.getValue()); } } }, localContext);
long start = System.currentTimeMillis(); HttpClient client = new DefaultHttpClient(); HttpGet request = new HttpGet("http://foo.com/cats.jpg"); HttpResponse response = client.execute(request); String size = response.getLastHeader("Content-Length").getValue(); long end = System.currentTimeMillis(); System.out.println("It took "+(end-start)+" milliseconds and the file is "+ size+" bytes long");
private long getLastModified(HttpResponse response) { Header last = response.getLastHeader("Last-Modified"); if (last == null) { return -1; } else { return DateUtils.parseDate(last.getValue()).getTime(); } }
private long getLastModified(HttpResponse response) { Header last = response.getLastHeader("Last-Modified"); if (last == null) { return -1; } else { return DateUtils.parseDate(last.getValue()).getTime(); } }
private String getContentType(HttpResponse method) { Header contentTypeHeader = method.getLastHeader("Content-Type"); String contentType = getContentType(contentTypeHeader); if (contentType == null) { // This should never happen either... return "application/octet-stream"; } else { return contentType; } }
private String getContentType(HttpResponse method) { Header contentTypeHeader = method.getLastHeader("Content-Type"); String contentType = getContentType(contentTypeHeader); if (contentType == null) { // This should never happen either... return "application/octet-stream"; } else { return contentType; } }
/** * {@inheritDoc} */ @Override public Header getLastHeader(String name) { return (response != null ? response.getLastHeader(name) : super.getLastHeader(name)); }
private DateTime getDateHeader(HttpResponse response, String name) { Header h = response.getLastHeader(name); if (h != null) { try { return new DateTime(DateUtils.parseDate(h.getValue()).getTime()); } catch (Exception ex) { log.warn("Invalid date '{}', will skip", h); } } return null; }
private String getContentBoundary(HttpResponse method) { Header contentTypeHeader = method.getLastHeader("Content-Type"); return getContentBoundary(contentTypeHeader); }