Refine search
protected void handleResponseInternal() throws IOException { Exchange exchange = outMessage.getExchange(); int responseCode = doProcessResponseCode(); inMessage.setExchange(exchange); updateResponseHeaders(inMessage); inMessage.put(Message.RESPONSE_CODE, responseCode); if (MessageUtils.getContextualBoolean(outMessage, SET_HTTP_RESPONSE_MESSAGE, false)) { inMessage.put(HTTP_RESPONSE_MESSAGE, getResponseMessage()); String charset = HttpHeaderHelper.findCharset((String)inMessage.get(Message.CONTENT_TYPE)); String normalizedEncoding = HttpHeaderHelper.mapCharset(charset); if (normalizedEncoding == null) { String m = new org.apache.cxf.common.i18n.Message("INVALID_ENCODING_MSG",
public void readFromConnection(HttpURLConnection connection) { Map<String, List<String>> origHeaders = connection.getHeaderFields(); headers.clear(); for (Entry<String, List<String>> entry : origHeaders.entrySet()) { if (entry.getKey() != null) { String key = HttpHeaderHelper.getHeaderKey(entry.getKey()); List<String> old = headers.get(key); if (old != null) { List<String> nl = new ArrayList<>(old.size() + entry.getValue().size()); nl.addAll(old); nl.addAll(entry.getValue()); headers.put(key, nl); } else { headers.put(key, entry.getValue()); } } } }
private String setEncoding(final Message inMessage, final HttpServletRequest req, final String contentType) throws IOException { String enc = HttpHeaderHelper.findCharset(contentType); if (enc == null) { enc = req.getCharacterEncoding(); } // work around a bug with Jetty which results in the character // encoding not being trimmed correctly. if (enc != null && enc.endsWith("\"")) { enc = enc.substring(0, enc.length() - 1); } if (enc != null || "POST".equals(req.getMethod()) || "PUT".equals(req.getMethod())) { //allow gets/deletes/options to not specify an encoding String normalizedEncoding = HttpHeaderHelper.mapCharset(enc); if (normalizedEncoding == null) { String m = new org.apache.cxf.common.i18n.Message("INVALID_ENCODING_MSG", LOG, enc).toString(); LOG.log(Level.WARNING, m); throw new IOException(m); } inMessage.put(Message.ENCODING, normalizedEncoding); } return contentType; } protected Message retrieveFromContinuation(HttpServletRequest req) {
if (supportedPayloadContentTypes != null && message.containsKey(Message.CONTENT_TYPE) && !supportedPayloadContentTypes.contains(message.get(Message.CONTENT_TYPE))) { return permitted; Object o = message.getContextualProperty(USE_GZIP_KEY); if (o instanceof UseGzip) { permitted = (UseGzip)o; if (requestHeaders != null) { List<String> acceptEncodingHeader = CastUtils.cast(HttpHeaderHelper .getHeader(requestHeaders, HttpHeaderHelper.ACCEPT_ENCODING)); List<String> jmsEncodingHeader = CastUtils.cast(requestHeaders.get(SOAP_JMS_CONTENTENCODING)); if (jmsEncodingHeader != null && jmsEncodingHeader.contains("gzip")) {
.get(Message.PROTOCOL_HEADERS)); if (protocolHeaders != null) { List<String> contentEncoding = HttpHeaderHelper.getHeader(protocolHeaders, HttpHeaderHelper.CONTENT_ENCODING); if (contentEncoding == null) { try { LOG.fine("Uncompressing response"); InputStream is = message.getContent(InputStream.class); if (is == null) { return; message.setContent(InputStream.class, zipInput);
protected void initializeRootMessage() throws IOException { contentType = (String) message.get(Message.CONTENT_TYPE); if (message.getContent(InputStream.class) == null) { throw new IllegalStateException("An InputStream must be provided!"); stream = new PushbackInputStream(message.getContent(InputStream.class), pbAmount); if (!readTillFirstBoundary(stream, boundary)) { String val = ih.getHeader("Content-Type", "; "); if (!StringUtils.isEmpty(val)) { String cs = HttpHeaderHelper.findCharset(val); if (!StringUtils.isEmpty(cs)) { message.put(Message.ENCODING, HttpHeaderHelper.mapCharset(cs));
public void handleMessage(Message message) { if (isGET(message) || message.getContent(XMLStreamReader.class) != null) { LOG.fine("StaxInInterceptor skipped."); return; InputStream is = message.getContent(InputStream.class); Reader reader = null; if (is == null) { reader = message.getContent(Reader.class); if (reader == null) { return; if (m != null) { List<String> contentLen = HttpHeaderHelper .getHeader(m, HttpHeaderHelper.CONTENT_LENGTH); List<String> contentTE = HttpHeaderHelper .getHeader(m, HttpHeaderHelper.CONTENT_TRANSFER_ENCODING); List<String> transferEncoding = HttpHeaderHelper .getHeader(m, HttpHeaderHelper.TRANSFER_ENCODING); if ((StringUtils.isEmpty(contentLen) || "0".equals(contentLen.get(0))) && StringUtils.isEmpty(contentTE)
public void handleMessage(Message message) throws Fault { Map<String, List<String>> headers = CastUtils.cast((Map)message.get(Message.PROTOCOL_HEADERS)); if (headers == null) { headers = new TreeMap<String, List<String>>(String.CASE_INSENSITIVE_ORDER); message.put(Message.PROTOCOL_HEADERS, headers); } String ct = (String)message.getExchange().get(Endpoint.class).get(HttpHeaderHelper.CONTENT_TYPE); if (ct != null) { List<String> contentType = new ArrayList<String>(); contentType.add(ct); headers.put(HttpHeaderHelper.getHeaderKey(HttpHeaderHelper.CONTENT_TYPE), contentType); message.put(HttpHeaderHelper.CONTENT_TYPE, ct); } }
static String getEncoding(String ct) throws UnsupportedEncodingException { String enc = HttpHeaderHelper.findCharset(ct); String normalizedEncoding = HttpHeaderHelper.mapCharset(enc, StandardCharsets.UTF_8.name()); if (normalizedEncoding == null) { String m = new org.apache.cxf.common.i18n.Message("INVALID_ENCODING_MSG", LOG, new Object[] { enc }).toString(); LOG.log(Level.WARNING, m); throw new UnsupportedEncodingException(m); } return normalizedEncoding; }
public static String mapCharset(String enc) { return mapCharset(enc, ISO88591); }
if (supportedPayloadContentTypes != null && message.containsKey(Message.CONTENT_TYPE) && !supportedPayloadContentTypes.contains(message.get(Message.CONTENT_TYPE))) { return permitted; Object o = message.getContextualProperty(USE_GZIP_KEY); if (o instanceof UseGzip) { permitted = (UseGzip)o; if (requestHeaders != null) { List<String> acceptEncodingHeader = CastUtils.cast(HttpHeaderHelper .getHeader(requestHeaders, HttpHeaderHelper.ACCEPT_ENCODING)); List<String> jmsEncodingHeader = CastUtils.cast(requestHeaders.get(SOAP_JMS_CONTENTENCODING)); if (jmsEncodingHeader != null && jmsEncodingHeader.contains("gzip")) {
.get(Message.PROTOCOL_HEADERS)); if (protocolHeaders != null) { List<String> contentEncoding = HttpHeaderHelper.getHeader(protocolHeaders, HttpHeaderHelper.CONTENT_ENCODING); if (contentEncoding == null) { try { LOG.fine("Uncompressing response"); InputStream is = message.getContent(InputStream.class); if (is == null) { return; message.setContent(InputStream.class, zipInput);
protected void initializeRootMessage() throws IOException { contentType = (String) message.get(Message.CONTENT_TYPE); if (message.getContent(InputStream.class) == null) { throw new IllegalStateException("An InputStream must be provided!"); stream = new PushbackInputStream(message.getContent(InputStream.class), PUSHBACK_AMOUNT); if (!readTillFirstBoundary(stream, boundary)) { throw new IOException("Couldn't find MIME boundary: " + boundaryString); String val = AttachmentUtil.getHeader(ih, "Content-Type", "; "); if (!StringUtils.isEmpty(val)) { String cs = HttpHeaderHelper.findCharset(val); if (!StringUtils.isEmpty(cs)) { message.put(Message.ENCODING, HttpHeaderHelper.mapCharset(cs));
public void handleMessage(Message message) { if (isGET(message) || message.getContent(XMLStreamReader.class) != null) { LOG.fine("StaxInInterceptor skipped."); return; InputStream is = message.getContent(InputStream.class); Reader reader = null; if (is == null) { reader = message.getContent(Reader.class); if (reader == null) { return; if (m != null) { List<String> contentLen = HttpHeaderHelper .getHeader(m, HttpHeaderHelper.CONTENT_LENGTH); List<String> contentTE = HttpHeaderHelper .getHeader(m, HttpHeaderHelper.CONTENT_TRANSFER_ENCODING); List<String> transferEncoding = HttpHeaderHelper .getHeader(m, HttpHeaderHelper.TRANSFER_ENCODING); if ((StringUtils.isEmpty(contentLen) || "0".equals(contentLen.get(0))) && StringUtils.isEmpty(contentTE)
private String setEncoding(final Message inMessage, final HttpServletRequest req, final String contentType) throws IOException { String enc = HttpHeaderHelper.findCharset(contentType); if (enc == null) { enc = req.getCharacterEncoding(); } // work around a bug with Jetty which results in the character // encoding not being trimmed correctly. if (enc != null && enc.endsWith("\"")) { enc = enc.substring(0, enc.length() - 1); } if (enc != null || "POST".equals(req.getMethod()) || "PUT".equals(req.getMethod())) { //allow gets/deletes/options to not specify an encoding String normalizedEncoding = HttpHeaderHelper.mapCharset(enc); if (normalizedEncoding == null) { String m = new org.apache.cxf.common.i18n.Message("INVALID_ENCODING_MSG", LOG, enc).toString(); LOG.log(Level.WARNING, m); throw new IOException(m); } inMessage.put(Message.ENCODING, normalizedEncoding); } return contentType; } protected Message retrieveFromContinuation(HttpServletRequest req) {
protected void setCharsetWithContentType(Exchange camelExchange) { // setup the charset from content-type header String contentTypeHeader = ExchangeHelper.getContentType(camelExchange); if (contentTypeHeader != null) { String charset = HttpHeaderHelper.findCharset(contentTypeHeader); String normalizedEncoding = HttpHeaderHelper.mapCharset(charset, Charset.forName("UTF-8").name()); if (normalizedEncoding != null) { camelExchange.setProperty(Exchange.CHARSET_NAME, normalizedEncoding); } } }
public static String mapCharset(String enc) { return mapCharset(enc, ISO88591); }
if (isRequestor(message)) { LOG.fine("Requestor role, so gzip enabled"); Object o = message.getContextualProperty(USE_GZIP_KEY); if (o instanceof UseGzip) { permitted = (UseGzip)o; permitted = force ? UseGzip.YES : UseGzip.NO; message.put(GZIP_ENCODING_KEY, "gzip"); addHeader(message, "Accept-Encoding", "gzip;q=1.0, identity; q=0.5, *;q=0"); } else { LOG.fine("Response role, checking accept-encoding"); Exchange exchange = message.getExchange(); Message request = exchange.getInMessage(); Map<String, List<String>> requestHeaders = CastUtils.cast((Map<?, ?>)request if (requestHeaders != null) { List<String> acceptEncodingHeader = CastUtils.cast(HttpHeaderHelper .getHeader(requestHeaders, HttpHeaderHelper.ACCEPT_ENCODING)); List<String> jmsEncodingHeader = CastUtils.cast(requestHeaders.get(SOAP_JMS_CONTENTENCODING)); if (jmsEncodingHeader != null && jmsEncodingHeader.contains("gzip")) {
.get(Message.PROTOCOL_HEADERS)); if (protocolHeaders != null) { List<String> contentEncoding = HttpHeaderHelper.getHeader(protocolHeaders, HttpHeaderHelper.CONTENT_ENCODING); if (contentEncoding == null) { try { LOG.fine("Uncompressing response"); InputStream is = message.getContent(InputStream.class); if (is == null) { return; message.setContent(InputStream.class, zipInput);
protected void handleResponseInternal() throws IOException { Exchange exchange = outMessage.getExchange(); int responseCode = doProcessResponseCode(); inMessage.setExchange(exchange); updateResponseHeaders(inMessage); inMessage.put(Message.RESPONSE_CODE, responseCode); propagateConduit(exchange, inMessage); String charset = HttpHeaderHelper.findCharset((String)inMessage.get(Message.CONTENT_TYPE)); String normalizedEncoding = HttpHeaderHelper.mapCharset(charset); if (normalizedEncoding == null) { String m = new org.apache.cxf.common.i18n.Message("INVALID_ENCODING_MSG",