use of org.apache.hc.client5.http.classic.methods.HttpPatch in project LinkAgent by shulieTech.
the class HttpClientv5MethodInterceptor method getParameters.
private Map getParameters(HttpRequest httpRequest) {
URI uri = null;
try {
uri = httpRequest.getUri();
} catch (URISyntaxException e) {
logger.error("获取不到url", e);
}
if (httpRequest instanceof HttpGet) {
HttpGet httpGet = (HttpGet) httpRequest;
return toMap(uri.getQuery());
}
if (httpRequest instanceof HttpPost) {
HttpPost httpPost = (HttpPost) httpRequest;
HttpEntity httpEntity = httpPost.getEntity();
Map parameters = toMap(uri.getQuery());
InputStream in = null;
try {
in = httpEntity.getContent();
parameters.putAll(toMap(toString(in)));
} catch (Throwable t) {
} finally {
if (in != null) {
try {
in.reset();
} catch (IOException e) {
}
}
}
return parameters;
}
if (httpRequest instanceof HttpPut) {
HttpPut httpPut = (HttpPut) httpRequest;
HttpEntity httpEntity = httpPut.getEntity();
Map parameters = toMap(uri.getQuery());
InputStream in = null;
try {
in = httpEntity.getContent();
parameters.putAll(toMap(toString(in)));
} catch (Throwable t) {
} finally {
if (in != null) {
try {
in.reset();
} catch (IOException e) {
}
}
}
return parameters;
}
if (httpRequest instanceof HttpDelete) {
HttpDelete httpDelete = (HttpDelete) httpRequest;
return toMap(uri.getQuery());
}
if (httpRequest instanceof HttpHead) {
HttpHead httpHead = (HttpHead) httpRequest;
return toMap(uri.getQuery());
}
if (httpRequest instanceof HttpOptions) {
HttpOptions httpOptions = (HttpOptions) httpRequest;
return toMap(uri.getQuery());
}
if (httpRequest instanceof HttpTrace) {
HttpTrace httpTrace = (HttpTrace) httpRequest;
return toMap(uri.getQuery());
}
if (httpRequest instanceof HttpPatch) {
HttpPatch httpPatch = (HttpPatch) httpRequest;
HttpEntity httpEntity = httpPatch.getEntity();
Map parameters = toMap(uri.getQuery());
InputStream in = null;
try {
in = httpEntity.getContent();
parameters.putAll(toMap(toString(in)));
} catch (Throwable t) {
} finally {
if (in != null) {
try {
in.reset();
} catch (IOException e) {
}
}
}
return parameters;
}
return Collections.EMPTY_MAP;
}
Aggregations