加解密只支持 content- type : application/json
This commit is contained in:
parent
13040c949e
commit
fd71ace2d9
@ -33,6 +33,7 @@ public class SacErrorCode {
|
||||
_ERROR.put(10016, "请求url被熔断");
|
||||
_ERROR.put(10017, "应用请求url被限流");
|
||||
_ERROR.put(10018, "apiCode与uri不匹配");
|
||||
_ERROR.put(10019, "请求不支持conetnt-type类型");
|
||||
};
|
||||
|
||||
public static JsonObject returnErrorMsg(Integer errorCode) {
|
||||
|
@ -393,8 +393,18 @@ public class ReverseProxy implements HttpProxy {
|
||||
if (isDataSecurity || circuitBreaker != null) {
|
||||
try {
|
||||
if (isDataSecurity && circuitBreaker != null) {
|
||||
// 加解密,只支持application/json
|
||||
String contentType = proxyRequest.headers().get(HttpHeaders.CONTENT_TYPE);
|
||||
if(StringUtils.equals(contentType, "application/json") == false) {
|
||||
throw new HttpException(10019);
|
||||
}
|
||||
return breakerAndSecurity(circuitBreaker, proxyRequest);
|
||||
} else if (isDataSecurity) {
|
||||
// 加解密,只支持application/json
|
||||
String contentType = proxyRequest.headers().get(HttpHeaders.CONTENT_TYPE);
|
||||
if(StringUtils.equals(contentType, "application/json") == false) {
|
||||
throw new HttpException(10019);
|
||||
}
|
||||
return security(circuitBreaker, proxyRequest);
|
||||
} else if (circuitBreaker != null) {
|
||||
return breaker(circuitBreaker, proxyRequest);
|
||||
@ -404,7 +414,11 @@ public class ReverseProxy implements HttpProxy {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new HttpException(10014);
|
||||
int errorCode = 10014;
|
||||
if (e instanceof HttpException) {
|
||||
errorCode = ((HttpException) e).getStatusCode();
|
||||
}
|
||||
throw new HttpException(errorCode);
|
||||
}
|
||||
} else {
|
||||
Future<HttpClientRequest> f = resolveOrigin(proxyRequest.proxiedRequest());
|
||||
|
Loading…
x
Reference in New Issue
Block a user