/** * Returns the character encoding of the response from the <tt>Content-Type</tt> header. * * @return String The character set. */ public String getResponseCharSet() { return getContentCharSet(getResponseHeader("Content-Type")); }
private String responseToErrorMessage(final HttpMethodBase method) { assert method.isRequestSent() : "no use getting an error message unless the request is sent"; if ("text/html".equals(method.getResponseHeader(CONTENT_TYPE).getValue())) { // The error message is the response content // Safety margin of 2048 characters, anything longer is probably useless // and will clutter the logs try { return method.getResponseBodyAsString(2048); } catch (IOException e) { S_LOGGER.debug("Error while loading response body", e); } } // The default return method.getStatusText(); }
private String responseToErrorMessage(final HttpMethodBase method) { assert method.isRequestSent() : "no use getting an error message unless the request is sent"; final Header contentTypeHeader = method.getResponseHeader(CONTENT_TYPE); if (contentTypeHeader != null && TEXT_HTML_CONTENT_TYPE.equals(contentTypeHeader.getValue())) { // The error message is the response content // Safety margin of 1024 characters, anything longer is probably // useless and will clutter the logs try { return method.getResponseBodyAsString(BODY_RESP_MAX_LEN); } catch (IOException e) { s_logger.debug("Error while loading response body", e); } } // The default return method.getStatusText(); } }
if (m.getStatusCode() == HttpStatus.SC_OK) { String hash = ""; if (m.getResponseHeader(HASH_MATCH) != null) { hash = m.getResponseHeader(HASH_MATCH).getValue(); set_hash(hash);
public Header getResponseHeader(String name) { try { return this.method.getResponseHeader(name); } catch (Exception e) { return null; } }
public Header getResponseHeader(String name) { try { return method.getResponseHeader(name); } catch (Exception e) { return null; } }
/** * @see HTTPResponse#getResponseHeader() */ public String getResponseHeader(String headerName) { Header header = method.getResponseHeader(headerName); String headerValue = null; if (header != null) { headerValue = header.getValue(); } return headerValue; }
@Override public String getResponseContentType() { Header responseHeader = httpClientMethod.getResponseHeader("Content-Type"); return null!=responseHeader?responseHeader.getValue():null; }
private static String getHeader(HttpMethodBase method, String headerName) { Header header = method.getResponseHeader(headerName); return (header == null) ? null : header.getValue().trim(); }
private static String getHeader(HttpMethodBase method, String headerName) { Header header = method.getResponseHeader(headerName); return (header == null) ? null : header.getValue().trim(); }
public long getResponseContentLength(HttpMethodBase method) { Header header = method.getResponseHeader("Content-Length"); if (header != null) { try { return Integer.parseInt(header.getValue()); } catch (NumberFormatException e) { Message.verbose("Invalid content-length value: " + e.getMessage()); } } return 0; }
/** * Returns the character encoding of the response from the <tt>Content-Type</tt> header. * * @return String The character set. */ public String getResponseCharSet() { return getContentCharSet(getResponseHeader("Content-Type")); }
/** * Returns the character encoding of the response from the <tt>Content-Type</tt> header. * * @return String The character set. */ public String getResponseCharSet() { return getContentCharSet(getResponseHeader("Content-Type")); }
/** * Returns the character encoding of the response from the <tt>Content-Type</tt> header. * * @return String The character set. */ public String getResponseCharSet() { return getContentCharSet(getResponseHeader("Content-Type")); }
/** * Returns the character encoding of the response from the <tt>Content-Type</tt> header. * * @return String The character set. */ public String getResponseCharSet() { return getContentCharSet(getResponseHeader("Content-Type")); }
/** * Returns the character encoding of the response from the <tt>Content-Type</tt> header. * * @return String The character set. */ public String getResponseCharSet() { return getContentCharSet(getResponseHeader("Content-Type")); }
private void prepareResponseProxyHeaders(HttpMethodBase method, HttpServletResponse response) { /* Copied from j2ep */ Header originalVia = method.getResponseHeader("via"); StringBuffer via = new StringBuffer(""); if (originalVia != null) { via.append(originalVia.getValue()).append(", "); } via.append(method.getStatusLine().getHttpVersion()).append(" ").append(SERVER_HOST_NAME); response.setHeader("via", via.toString()); }
protected boolean isResponseGzipCompressed(XmlRpcStreamRequestConfig pConfig) { Header h = method.getResponseHeader( "Content-Encoding" ); if (h == null) { return false; } else { return HttpUtil.isUsingGzipEncoding(h.getValue()); } }
protected boolean isResponseGzipCompressed() { Header h = method.getResponseHeader( "Content-Encoding" ); if (h == null) { return false; } else { return HttpUtil.isUsingGzipEncoding(h.getValue()); } }
private Transferable initBasicResponseTransferable(HttpMethodBase method) throws IOException, HttpException { m_client.executeMethod(method); Header contentTypeHeader = method.getResponseHeader("Content-Type"); String contentType = contentTypeHeader != null ? contentTypeHeader.getValue() : ""; Transferable trans = TransferableFactory.getInstance().createStreamTransferable(contentType, method.getResponseBodyAsStream(), method.getResponseCharSet()); return trans; }