mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix code
This commit is contained in:
@@ -21,7 +21,7 @@ public class HttpConfig {
|
||||
*
|
||||
* @return HttpConfig
|
||||
*/
|
||||
public static HttpConfig create() {
|
||||
public static HttpConfig of() {
|
||||
return new HttpConfig();
|
||||
}
|
||||
|
||||
|
@@ -42,8 +42,8 @@ public class HttpConnection {
|
||||
* @param proxy 代理,无代理传{@code null}
|
||||
* @return HttpConnection
|
||||
*/
|
||||
public static HttpConnection create(final String urlStr, final Proxy proxy) {
|
||||
return create(URLUtil.toUrlForHttp(urlStr), proxy);
|
||||
public static HttpConnection of(final String urlStr, final Proxy proxy) {
|
||||
return of(URLUtil.toUrlForHttp(urlStr), proxy);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,7 +53,7 @@ public class HttpConnection {
|
||||
* @param proxy 代理,无代理传{@code null}
|
||||
* @return HttpConnection
|
||||
*/
|
||||
public static HttpConnection create(final URL url, final Proxy proxy) {
|
||||
public static HttpConnection of(final URL url, final Proxy proxy) {
|
||||
return new HttpConnection(url, proxy);
|
||||
}
|
||||
|
||||
|
@@ -211,7 +211,7 @@ public class HttpRequest extends HttpBase<HttpRequest> {
|
||||
}
|
||||
// ---------------------------------------------------------------- static Http Method end
|
||||
|
||||
private HttpConfig config = HttpConfig.create();
|
||||
private HttpConfig config = HttpConfig.of();
|
||||
private UrlBuilder url;
|
||||
private URLStreamHandler urlHandler;
|
||||
private Method method = Method.GET;
|
||||
@@ -1141,7 +1141,7 @@ public class HttpRequest extends HttpBase<HttpRequest> {
|
||||
this.httpConnection = HttpConnection
|
||||
// issue#I50NHQ
|
||||
// 在生成正式URL前,设置自定义编码
|
||||
.create(this.url.setCharset(this.charset).toURL(this.urlHandler), config.proxy)//
|
||||
.of(this.url.setCharset(this.charset).toURL(this.urlHandler), config.proxy)//
|
||||
.setConnectTimeout(config.connectionTimeout)//
|
||||
.setReadTimeout(config.readTimeout)//
|
||||
.setMethod(this.method)//
|
||||
@@ -1263,9 +1263,9 @@ public class HttpRequest extends HttpBase<HttpRequest> {
|
||||
// Write的时候会优先使用body中的内容,write时自动关闭OutputStream
|
||||
final RequestBody body;
|
||||
if (ArrayUtil.isNotEmpty(this.bodyBytes)) {
|
||||
body = BytesBody.create(this.bodyBytes);
|
||||
body = BytesBody.of(this.bodyBytes);
|
||||
} else {
|
||||
body = FormUrlEncodedBody.create(this.form, this.charset);
|
||||
body = FormUrlEncodedBody.of(this.form, this.charset);
|
||||
}
|
||||
body.writeClose(this.httpConnection.getOutputStream());
|
||||
}
|
||||
@@ -1277,7 +1277,7 @@ public class HttpRequest extends HttpBase<HttpRequest> {
|
||||
* @throws IOException IO异常
|
||||
*/
|
||||
private void sendMultipart() throws IOException {
|
||||
final MultipartBody multipartBody = MultipartBody.create(this.form, this.charset);
|
||||
final MultipartBody multipartBody = MultipartBody.of(this.form, this.charset);
|
||||
//设置表单类型为Multipart(文件上传)
|
||||
this.httpConnection.header(Header.CONTENT_TYPE, multipartBody.getContentType(), true);
|
||||
multipartBody.writeClose(this.httpConnection.getOutputStream());
|
||||
|
@@ -19,7 +19,7 @@ public class BytesBody implements RequestBody {
|
||||
* @param content body内容,编码后
|
||||
* @return BytesBody
|
||||
*/
|
||||
public static BytesBody create(final byte[] content){
|
||||
public static BytesBody of(final byte[] content){
|
||||
return new BytesBody(content);
|
||||
}
|
||||
|
||||
|
@@ -21,7 +21,7 @@ public class FormUrlEncodedBody extends BytesBody {
|
||||
* @param charset 编码
|
||||
* @return FormUrlEncodedBody
|
||||
*/
|
||||
public static FormUrlEncodedBody create(final Map<String, Object> form, final Charset charset) {
|
||||
public static FormUrlEncodedBody of(final Map<String, Object> form, final Charset charset) {
|
||||
return new FormUrlEncodedBody(form, charset);
|
||||
}
|
||||
|
||||
|
@@ -42,7 +42,7 @@ public class MultipartBody implements RequestBody {
|
||||
* @param charset 编码
|
||||
* @return MultipartBody
|
||||
*/
|
||||
public static MultipartBody create(final Map<String, Object> form, final Charset charset) {
|
||||
public static MultipartBody of(final Map<String, Object> form, final Charset charset) {
|
||||
return new MultipartBody(form, charset);
|
||||
}
|
||||
|
||||
|
@@ -104,7 +104,7 @@ public class SoapClient extends HttpBase<SoapClient> {
|
||||
* @param url WS的URL地址
|
||||
* @return this
|
||||
*/
|
||||
public static SoapClient create(final String url) {
|
||||
public static SoapClient of(final String url) {
|
||||
return new SoapClient(url);
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ public class SoapClient extends HttpBase<SoapClient> {
|
||||
* @param protocol 协议,见{@link SoapProtocol}
|
||||
* @return this
|
||||
*/
|
||||
public static SoapClient create(final String url, final SoapProtocol protocol) {
|
||||
public static SoapClient of(final String url, final SoapProtocol protocol) {
|
||||
return new SoapClient(url, protocol);
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ public class SoapClient extends HttpBase<SoapClient> {
|
||||
* @return this
|
||||
* @since 4.5.6
|
||||
*/
|
||||
public static SoapClient create(final String url, final SoapProtocol protocol, final String namespaceURI) {
|
||||
public static SoapClient of(final String url, final SoapProtocol protocol, final String namespaceURI) {
|
||||
return new SoapClient(url, protocol, namespaceURI);
|
||||
}
|
||||
|
||||
|
@@ -27,7 +27,7 @@ public class SoapUtil {
|
||||
* @return {@link SoapClient}
|
||||
*/
|
||||
public static SoapClient createClient(final String url) {
|
||||
return SoapClient.create(url);
|
||||
return SoapClient.of(url);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -38,7 +38,7 @@ public class SoapUtil {
|
||||
* @return {@link SoapClient}
|
||||
*/
|
||||
public static SoapClient createClient(final String url, final SoapProtocol protocol) {
|
||||
return SoapClient.create(url, protocol);
|
||||
return SoapClient.of(url, protocol);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,7 +51,7 @@ public class SoapUtil {
|
||||
* @since 4.5.6
|
||||
*/
|
||||
public static SoapClient createClient(final String url, final SoapProtocol protocol, final String namespaceURI) {
|
||||
return SoapClient.create(url, protocol, namespaceURI);
|
||||
return SoapClient.of(url, protocol, namespaceURI);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -20,7 +20,7 @@ public class MultipartBodyTest {
|
||||
form.put("pic3", new HttpResource(
|
||||
new StringResource("pic3 content", "pic3.jpg"), "image/jpeg"));
|
||||
|
||||
final MultipartBody body = MultipartBody.create(form, CharsetUtil.UTF_8);
|
||||
final MultipartBody body = MultipartBody.of(form, CharsetUtil.UTF_8);
|
||||
|
||||
Assert.assertNotNull(body.toString());
|
||||
// Console.log(body);
|
||||
|
@@ -19,7 +19,7 @@ public class SoapClientTest {
|
||||
@Test
|
||||
@Ignore
|
||||
public void requestTest() {
|
||||
final SoapClient client = SoapClient.create("http://www.webxml.com.cn/WebServices/IpAddressSearchWebService.asmx")
|
||||
final SoapClient client = SoapClient.of("http://www.webxml.com.cn/WebServices/IpAddressSearchWebService.asmx")
|
||||
.setMethod("web:getCountryCityByIp", "http://WebXml.com.cn/")
|
||||
.setCharset(CharsetUtil.GBK)
|
||||
.setParam("theIpAddress", "218.21.240.106");
|
||||
@@ -32,7 +32,7 @@ public class SoapClientTest {
|
||||
@Test
|
||||
@Ignore
|
||||
public void requestForMessageTest() throws SOAPException {
|
||||
final SoapClient client = SoapClient.create("http://www.webxml.com.cn/WebServices/IpAddressSearchWebService.asmx")
|
||||
final SoapClient client = SoapClient.of("http://www.webxml.com.cn/WebServices/IpAddressSearchWebService.asmx")
|
||||
.setMethod("web:getCountryCityByIp", "http://WebXml.com.cn/")
|
||||
.setParam("theIpAddress", "218.21.240.106");
|
||||
|
||||
|
Reference in New Issue
Block a user