@Test public void postBodyCopied() throws Exception { HttpRequest request = new HttpRequest(DEFAULT_URI).setPostBody(POST_BODY.getBytes()); assertEquals(POST_BODY.length(), request.getPostBodyLength()); assertEquals(POST_BODY, IOUtils.toString(request.getPostBody(), "UTF-8")); assertEquals(POST_BODY, request.getPostBodyAsString()); }
/** * Copies the post data from HttpServletRequest object to HttpRequest object. * @param origRequest Request to copy post data from. * @param req The HttpRequest object to copy post data to. * @throws GadgetException In case of errors. */ public static void copyRequestData(HttpRequest origRequest, HttpRequest req) throws GadgetException { req.setMethod(origRequest.getMethod()); try { if (origRequest.getMethod().equalsIgnoreCase("post")) { req.setPostBody(origRequest.getPostBody()); } } catch (IOException e) { throw new GadgetException(GadgetException.Code.INTERNAL_SERVER_ERROR, e); } }
enclosingMethod.setEntity(new InputStreamEntity(request.getPostBody(), request.getPostBodyLength()));
case URL_AND_BODY_HASH: try { byte[] body = IOUtils.toByteArray(base.getPostBody()); byte[] hash = DigestUtils.sha(body); String b64 = new String(Base64.encodeBase64(hash), Charsets.UTF_8.name());
@Test public void postBodyCopied() throws Exception { HttpRequest request = new HttpRequest(DEFAULT_URI).setPostBody(POST_BODY.getBytes()); assertEquals(POST_BODY.length(), request.getPostBodyLength()); assertEquals(POST_BODY, IOUtils.toString(request.getPostBody(), "UTF-8")); assertEquals(POST_BODY, request.getPostBodyAsString()); }
case URL_AND_BODY_HASH: try { byte[] body = IOUtils.toByteArray(base.getPostBody()); byte[] hash = DigestUtils.sha(body); String b64 = new String(Base64.encodeBase64(hash), Charsets.UTF_8.name());
enclosingMethod.setEntity(new InputStreamEntity(request.getPostBody(), request.getPostBodyLength()));
/** * Copies the post data from HttpServletRequest object to HttpRequest object. * @param origRequest Request to copy post data from. * @param req The HttpRequest object to copy post data to. * @throws GadgetException In case of errors. */ public static void copyRequestData(HttpRequest origRequest, HttpRequest req) throws GadgetException { req.setMethod(origRequest.getMethod()); try { if (origRequest.getMethod().equalsIgnoreCase("post")) { req.setPostBody(origRequest.getPostBody()); } } catch (IOException e) { throw new GadgetException(GadgetException.Code.INTERNAL_SERVER_ERROR, e); } }
@Test public void postBodyCopied() throws Exception { HttpRequest request = new HttpRequest(DEFAULT_URI).setPostBody(POST_BODY.getBytes()); assertEquals(POST_BODY.length(), request.getPostBodyLength()); assertEquals(POST_BODY, IOUtils.toString(request.getPostBody(), "UTF-8")); assertEquals(POST_BODY, request.getPostBodyAsString()); }
if (addBodyHash) { try { byte[] body = IOUtils.toByteArray(base.getPostBody()); byte[] hash = DigestUtils.sha(body); String b64 = CharsetUtil.newUtf8String(Base64.encodeBase64(hash));
enclosingMethod.setEntity(new InputStreamEntity(request.getPostBody(), request.getPostBodyLength()));
/** * Copies the post data from HttpServletRequest object to HttpRequest object. * @param origRequest Request to copy post data from. * @param req The HttpRequest object to copy post data to. * @throws GadgetException In case of errors. */ public static void copyRequestData(HttpRequest origRequest, HttpRequest req) throws GadgetException { req.setMethod(origRequest.getMethod()); try { if (origRequest.getMethod().equalsIgnoreCase("post")) { req.setPostBody(origRequest.getPostBody()); } } catch (IOException e) { throw new GadgetException(GadgetException.Code.INTERNAL_SERVER_ERROR, e); } }
info.rawBody = IOUtils.toByteArray(request.getPostBody()); } catch (IOException e) { throw new RuntimeException("Can't read post body bytes", e);
info.rawBody = IOUtils.toByteArray(request.getPostBody()); } catch (IOException e) { throw new RuntimeException("Can't read post body bytes", e);
info.rawBody = IOUtils.toByteArray(request.getPostBody()); } catch (IOException e) { throw new RuntimeException("Can't read post body bytes", e);