|
|
@ -2,22 +2,18 @@ package au.com.royalpay.payment.manage.shopify.support;
|
|
|
|
|
|
|
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.springframework.web.util.ContentCachingRequestWrapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import java.io.BufferedReader;
|
|
|
|
import java.io.BufferedReader;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class ShopifyHttpUtils {
|
|
|
|
public class ShopifyHttpUtils {
|
|
|
|
private ShopifyHttpUtils(){}
|
|
|
|
private ShopifyHttpUtils() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(ShopifyHttpUtils.class);
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(ShopifyHttpUtils.class);
|
|
|
|
|
|
|
|
|
|
|
|
public static String getRequestBody(HttpServletRequest request) {
|
|
|
|
public static String getRequestBody(HttpServletRequest request) {
|
|
|
|
if (request instanceof ContentCachingRequestWrapper) {
|
|
|
|
|
|
|
|
logger.info("Shopify Request Cached, read directly");
|
|
|
|
|
|
|
|
return new String(((ContentCachingRequestWrapper) request).getContentAsByteArray(), StandardCharsets.UTF_8);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
BufferedReader br = null;
|
|
|
|
BufferedReader br = null;
|
|
|
|
StringBuilder sb = new StringBuilder("");
|
|
|
|
StringBuilder sb = new StringBuilder("");
|
|
|
|
try {
|
|
|
|
try {
|
|
|
@ -39,6 +35,8 @@ public class ShopifyHttpUtils {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return sb.toString();
|
|
|
|
String body = sb.toString();
|
|
|
|
|
|
|
|
logger.debug("Shopify read body |-{}", body);
|
|
|
|
|
|
|
|
return body;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|