top.jfunc.http.component.jodd.DefaultJoddBodyContentCallbackCreator Maven / Gradle / Ivy
package top.jfunc.http.component.jodd;
import jodd.http.HttpRequest;
import top.jfunc.http.base.MediaType;
import top.jfunc.http.base.ContentCallback;
import top.jfunc.http.component.AbstractBodyContentCallbackCreator;
import top.jfunc.http.request.StringBodyRequest;
import java.io.IOException;
/**
* @author xiongshiyan at 2020/1/7 , contact me with email [email protected] or phone 15208384257
*/
public class DefaultJoddBodyContentCallbackCreator extends AbstractBodyContentCallbackCreator {
@Override
protected ContentCallback doCreate(StringBodyRequest stringBodyRequest) throws IOException {
String contentType = stringBodyRequest.getContentType();
String bodyCharset = stringBodyRequest.calculateBodyCharset();
String type = null == contentType ?
MediaType.APPLICATION_JSON.withCharset(bodyCharset).toString() : contentType;
return httpRequest -> httpRequest.bodyText(stringBodyRequest.getBody() , type, bodyCharset);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy