return EncodingUtil.getString(rawdata, getResponseCharSet()); } else { return null;
/** * Returns the response body of the HTTP method, if any, as a {@link String}. * If response body is not available or cannot be read, returns <tt>null</tt> * The string conversion on the data is done using the character encoding specified * in <tt>Content-Type</tt> header. Buffers the response and this method can be * called several times yielding the same result each time. * * Note: This will cause the entire response body to be buffered in memory. A * malicious server may easily exhaust all the VM memory. It is strongly * recommended, to use getResponseAsStream if the content length of the response * is unknown or resonably large. * * @return The response body or <code>null</code>. * * @throws IOException If an I/O (transport) problem occurs while obtaining the * response body. */ public String getResponseBodyAsString() throws IOException { byte[] rawdata = null; if (responseAvailable()) { rawdata = getResponseBody(); } if (rawdata != null) { return EncodingUtil.getString(rawdata, getResponseCharSet()); } else { return null; } }
@Override public String getResponseCharset() { String responseCharSet = null; if (methodResponse instanceof HttpMethodBase) { responseCharSet = ((HttpMethodBase) methodResponse).getResponseCharSet(); } return responseCharSet; } }
/** * @return * @see org.geotools.data.ows.HTTPResponse#getResponseCharset() */ @Override public String getResponseCharset() { String responseCharSet = null; if (methodResponse instanceof HttpMethodBase) { responseCharSet = ((HttpMethodBase) methodResponse).getResponseCharSet(); } return responseCharSet; } }
/** * @return * @see org.geotools.data.ows.HTTPResponse#getResponseCharset() */ @Override public String getResponseCharset() { String responseCharSet = null; if (methodResponse instanceof HttpMethodBase) { responseCharSet = ((HttpMethodBase) methodResponse).getResponseCharSet(); } return responseCharSet; } }
public String getResponseCharset() { String responseCharSet = method.getResponseCharSet(); return responseCharSet; }
@Override public String getResponseCharset() { String responseCharSet = null; if (methodResponse instanceof HttpMethodBase) { responseCharSet = ((HttpMethodBase) methodResponse).getResponseCharSet(); } return responseCharSet; } }
@Override public String getResponseCharacterEncoding() { return httpClientMethod.getResponseCharSet(); }
/** Return m's response body as a string, optionally limiting the length that we read * @param maxLength if 0, no limit */ public static String getResponseBodyAsStream(HttpMethodBase m, int maxLength) throws IOException { final InputStream is = m.getResponseBodyAsStream(); final StringBuilder content = new StringBuilder(); final String charset = m.getResponseCharSet(); final byte [] buffer = new byte[16384]; int n = 0; while( (n = is.read(buffer, 0, buffer.length)) > 0) { content.append(new String(buffer, 0, n, charset)); if(maxLength != 0 && content.length() > maxLength) { throw new IllegalArgumentException("Response body size is over maxLength (" + maxLength + ")"); } } return content.toString(); }
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; }
private SimpleResponse executeSimpleRequest(final HttpMethodBase request) throws IOException { int status = getClient().executeMethod(request); return parseSimpleResponse(status, request.getStatusText(), request.getResponseBodyAsStream(), request.getResponseCharSet()); }
private DetailedResponse executeDetailedRequest(final HttpMethodBase request, final ResponseProgressListener listener) throws IOException { int status = getClient().executeMethod(request); return parseDetailedResponse(status, request.getStatusText(), request.getResponseBodyAsStream(), request.getResponseCharSet(), listener); }
private ListResponse executeListRequest(final HttpMethodBase request) throws IOException { int status = getClient().executeMethod(request); return parseListResponse(status, request.getStatusText(), request.getResponseBodyAsStream(), request.getResponseCharSet()); }
return EncodingUtil.getString(rawdata, getResponseCharSet()); } else { return null;
/** * Returns the response body of the HTTP method, if any, as a {@link String}. * If response body is not available or cannot be read, returns <tt>null</tt> * The string conversion on the data is done using the character encoding specified * in <tt>Content-Type</tt> header. Buffers the response and this method can be * called several times yielding the same result each time. * * Note: This will cause the entire response body to be buffered in memory. A * malicious server may easily exhaust all the VM memory. It is strongly * recommended, to use getResponseAsStream if the content length of the response * is unknown or resonably large. * * @return The response body or <code>null</code>. * * @throws IOException If an I/O (transport) problem occurs while obtaining the * response body. */ public String getResponseBodyAsString() throws IOException { byte[] rawdata = null; if (responseAvailable()) { rawdata = getResponseBody(); } if (rawdata != null) { return EncodingUtil.getString(rawdata, getResponseCharSet()); } else { return null; } }
/** * Returns the response body of the HTTP method, if any, as a {@link String}. * If response body is not available or cannot be read, returns <tt>null</tt> * The string conversion on the data is done using the character encoding specified * in <tt>Content-Type</tt> header. Buffers the response and this method can be * called several times yielding the same result each time. * * Note: This will cause the entire response body to be buffered in memory. A * malicious server may easily exhaust all the VM memory. It is strongly * recommended, to use getResponseAsStream if the content length of the response * is unknown or resonably large. * * @return The response body or <code>null</code>. * * @throws IOException If an I/O (transport) problem occurs while obtaining the * response body. */ public String getResponseBodyAsString() throws IOException { byte[] rawdata = null; if (responseAvailable()) { rawdata = getResponseBody(); } if (rawdata != null) { return EncodingUtil.getString(rawdata, getResponseCharSet()); } else { return null; } }
/** * Returns the response body of the HTTP method, if any, as a {@link String}. * If response body is not available or cannot be read, returns <tt>null</tt> * The string conversion on the data is done using the character encoding specified * in <tt>Content-Type</tt> header. Buffers the response and this method can be * called several times yielding the same result each time. * * Note: This will cause the entire response body to be buffered in memory. A * malicious server may easily exhaust all the VM memory. It is strongly * recommended, to use getResponseAsStream if the content length of the response * is unknown or resonably large. * * @return The response body or <code>null</code>. * * @throws IOException If an I/O (transport) problem occurs while obtaining the * response body. */ @Override public String getResponseBodyAsString() throws IOException { byte[] rawdata = null; if (responseAvailable()) { rawdata = getResponseBody(); } if (rawdata != null) { return EncodingUtil.getString(rawdata, getResponseCharSet()); } else { return null; } }
/** * Returns the response body of the HTTP method, if any, as a {@link String}. * If response body is not available or cannot be read, returns <tt>null</tt> * The string conversion on the data is done using the character encoding specified * in <tt>Content-Type</tt> header. Buffers the response and this method can be * called several times yielding the same result each time. * * Note: This will cause the entire response body to be buffered in memory. A * malicious server may easily exhaust all the VM memory. It is strongly * recommended, to use getResponseAsStream if the content length of the response * is unknown or resonably large. * * @return The response body or <code>null</code>. * * @throws IOException If an I/O (transport) problem occurs while obtaining the * response body. */ public String getResponseBodyAsString() throws IOException { byte[] rawdata = null; if (responseAvailable()) { rawdata = getResponseBody(); } if (rawdata != null) { return EncodingUtil.getString(rawdata, getResponseCharSet()); } else { return null; } }
/** * Returns the response body of the HTTP method, if any, as a {@link String}. * If response body is not available or cannot be read, returns <tt>null</tt> * The string conversion on the data is done using the character encoding specified * in <tt>Content-Type</tt> header. Buffers the response and this method can be * called several times yielding the same result each time. * * Note: This will cause the entire response body to be buffered in memory. A * malicious server may easily exhaust all the VM memory. It is strongly * recommended, to use getResponseAsStream if the content length of the response * is unknown or resonably large. * * @return The response body or <code>null</code>. * * @throws IOException If an I/O (transport) problem occurs while obtaining the * response body. */ public String getResponseBodyAsString() throws IOException { byte[] rawdata = null; if (responseAvailable()) { rawdata = getResponseBody(); } if (rawdata != null) { return EncodingUtil.getString(rawdata, getResponseCharSet()); } else { return null; } }
RDFParser parser = getParser(response); InputStream in = response.getResponseBodyAsStream(); String charset_str = response.getResponseCharSet(); Charset charset; try {