/** * Creates a new StreamPayload. */ public StreamPayload(final InputStream pIn, final String pCharset) throws IOException { m_charset = pCharset; m_originalBytes = copyStream(pIn); }
public TextualPayload toTextualPayload() { try { return new TextualPayload(getAsStream(), m_charset); } catch (IOException e) { LOG.error("Cannot convert to textual payload", e); return new TextualPayload(toString(), m_charset); } } }
private void setPayloadAsStreamPayload(Transferable requestTransferable) throws IOException { ByteArrayInputStream bais = new ByteArrayInputStream(base64DecodePayload(requestTransferable.getPayload())); requestTransferable.setPayload(new StreamPayload(bais, "UTF-8")); }
if (contentType != null && contentType.startsWith("application/octe") && (pPayload instanceof StreamPayload)) { StreamPayload lStreamPayload = (StreamPayload) pPayload; lPayloadAsString = new String(Base64.encodeBase64(lStreamPayload.toByteArray())); } else { lPayloadAsString = pPayload.toString();
private Payload buildPayloadFromPost(HttpServletRequest servletRequest) throws IOException { Payload payload; if (servletRequest.getContentType() != null && servletRequest.getContentType().contains("x-www-form")) { // create querystring payload from parsed parameters payload = getFullQueryString(servletRequest); } else { BufferedInputStream stream = new BufferedInputStream(servletRequest.getInputStream()); if (isInputStreamAvailable(stream)) { if (servletRequest.getContentType().contains("multipart/form-data")) { payload = new StreamPayload(stream, getNullSafeEncoding(servletRequest)); } else { payload = new TextualPayload(stream, getNullSafeEncoding(servletRequest)); } } else { // maybe the body was parsed as parameters! e.g. if // AuthenticationProcessors perform req.getParameter // but this is only the case if contenttype is: // x-www-form-urlencoded or null if (servletRequest.getContentType() == null) { // create querystring payload from parsed parameters payload = getFullQueryString(servletRequest); } else { // no body payload = new TextualPayload("", getNullSafeEncoding(servletRequest)); } } } return payload; }
public Transferable createStreamTransferable(final String pContentType, final InputStream pPayLoad, final String pCharset) throws IOException { Transferable lTransferable = new TransferableImpl(); lTransferable.setPayload(new StreamPayload(pPayLoad, pCharset)); if (pContentType != null) { String contentType = addCharset(pContentType, pCharset); lTransferable.addAttribute(HttpHeaderAttribute.createHttpHeaderAttribute( HttpHeaderAttribute.HEADER_NAME_CONTENTTYPE, contentType)); } if (pCharset != null) { lTransferable.addAttribute(HttpHeaderAttribute.createHttpHeaderAttribute( HttpHeaderAttribute.HEADER_NAME_CONTENTCHARSET, pCharset)); } return lTransferable; }