Skip to content

Commit

Permalink
Merge pull request EliMirren#3 from EliMirren/dev
Browse files Browse the repository at this point in the history
完成Http服务基本功能
  • Loading branch information
shenzhenMirren authored May 7, 2018
2 parents cb124f7 + 3229a0c commit 20e616f
Show file tree
Hide file tree
Showing 12 changed files with 479 additions and 289 deletions.
30 changes: 30 additions & 0 deletions src/main/java/com/szmirren/vxApi/core/common/StrUtil.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package com.szmirren.vxApi.core.common;

import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.format.DateTimeParseException;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.SimpleTimeZone;

import com.szmirren.vxApi.core.enums.ParamTypeEnum;

Expand Down Expand Up @@ -196,6 +199,17 @@ public static String replace(String str, List<String[]> rep) {
public static String[] asStrArray(String... str) {
return str;
}
/**
* 获得RFC822规范的Date
*
* @param date
* @return
*/
public static String getRfc822DateFormat(Date date) {
SimpleDateFormat rfc822DateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US);
rfc822DateFormat.setTimeZone(new SimpleTimeZone(0, "GMT"));
return rfc822DateFormat.format(date);
}

/**
* 判断字符串是否为null或者空,如果是返回true
Expand Down Expand Up @@ -393,6 +407,22 @@ public static long getlong(String str) throws NumberFormatException {
}
return new Long(str);
}
/**
* 将一个字符串转换为long,如果字符串为null或者""返回0
*
* @param str
*/
public static long getlongTry(String str) {
if (isNullOrEmpty(str)) {
return 0l;
}
try {
return new Long(str);
} catch (NumberFormatException e) {
return 0l;
}
}

/**
* 将一个字符串转换为Long,如果字符串为null或者""返回null
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public class VxApiTrackInfos {
private Instant endTime;// 主业务处理结束时间
private Instant requestTime;// 与后端服务器交互开始时间
private Instant responseTime;// 与后端服务器交互相应时间
private int requestBufferLen;// 用户请求的的主体buffer长度
private int responseBufferLen;// 服务端响应的主体buffer长度
private long requestBufferLen;// 用户请求的的主体buffer长度
private long responseBufferLen;// 服务端响应的主体buffer长度
private boolean successful = true;// 是否成功
private String errMsg;// 异常信息
private String errStackTrace;// 异常信息
Expand Down Expand Up @@ -208,7 +208,7 @@ public void setResponseTime(Instant responseTime) {
*
* @return
*/
public int getRequestBufferLen() {
public long getRequestBufferLen() {
return requestBufferLen;
}

Expand All @@ -217,7 +217,7 @@ public int getRequestBufferLen() {
*
* @param requestBufferLen
*/
public void setRequestBufferLen(int requestBufferLen) {
public void setRequestBufferLen(long requestBufferLen) {
this.requestBufferLen = requestBufferLen;
}

Expand All @@ -226,7 +226,7 @@ public void setRequestBufferLen(int requestBufferLen) {
*
* @return
*/
public int getResponseBufferLen() {
public long getResponseBufferLen() {
return responseBufferLen;
}

Expand All @@ -235,7 +235,7 @@ public int getResponseBufferLen() {
*
* @param responseBufferLen
*/
public void setResponseBufferLen(int responseBufferLen) {
public void setResponseBufferLen(long responseBufferLen) {
this.responseBufferLen = responseBufferLen;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ public enum ContentTypeEnum {
/** 内容: application/x-www-form-urlencoded;charset=UTF-8 */
FORM_UTF8("application/x-www-form-urlencoded;charset=UTF-8"),
/** 内容: application/octet-stream;charset=UTF-8 */
BINARY_UTF8("application/octet-stream;charset=UTF-8"),
/** 内容: Content-Type */
CONTENT_TYPE("Content-Type");
BINARY_UTF8("application/octet-stream;charset=UTF-8");

private String type;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@
*
*/
public interface VxApiRouteConstant {
/**
* 返回类型
*/
/** 返回类型 Content-Type */
public final static String CONTENT_TYPE = "Content-Type";
/**
* 服务器类型
*/
/** 时间 Content-Length */
public final static String CONTENT_LENGTH = "Content-Length";
/** 服务器类型 Server */
public final static String SERVER = "Server";
/** 服务器类型 User-Agent */
public final static String USER_AGENT = "User-Agent";
/** 时间 Date */
public final static String DATE = "Date";

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public interface VxApiRouteHandlerHttpService extends Handler<RoutingContext> {
* @param appName
* @return
*/
static VxApiRouteHandlerHttpService create(String appName, boolean isNext, VxApis api, HttpClient httpClient)
static VxApiRouteHandlerHttpService create(String appName, long maxContentLength, boolean isNext, VxApis api, HttpClient httpClient)
throws NullPointerException, MalformedURLException {
return new VxApiRouteHandlerHttpServiceImpl(appName, isNext, api, httpClient);
return new VxApiRouteHandlerHttpServiceImpl(appName, maxContentLength, isNext, api, httpClient);
}
}
Loading

0 comments on commit 20e616f

Please sign in to comment.