private void setPayloadAsStreamPayload(Transferable requestTransferable) throws IOException { ByteArrayInputStream bais = new ByteArrayInputStream(base64DecodePayload(requestTransferable.getPayload())); requestTransferable.setPayload(new StreamPayload(bais, "UTF-8")); }
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; }