query param encoding, decoding 처리
This commit is contained in:
@@ -30,6 +30,7 @@ import io.netty.handler.ssl.SslContext;
|
||||
import io.netty.handler.ssl.SslContextBuilder;
|
||||
import io.netty.handler.ssl.util.InsecureTrustManagerFactory;
|
||||
import io.netty.util.CharsetUtil;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import javax.net.ssl.SSLException;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -84,8 +85,18 @@ public class NettyHttpApiClient implements ApiClient {
|
||||
}
|
||||
|
||||
String fullPath = server.getBasePath() + apiRequest.getPath();
|
||||
String encodedPath = fullPath;
|
||||
|
||||
HttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.valueOf(apiRequest.getMethod()), fullPath, content);
|
||||
// Check if the fullPath contains query parameters
|
||||
int queryIndex = fullPath.indexOf('?');
|
||||
if (queryIndex != -1) {
|
||||
String path = fullPath.substring(0, queryIndex);
|
||||
String queryParams = fullPath.substring(queryIndex + 1);
|
||||
String encodedQueryParams = URLEncoder.encode(queryParams);
|
||||
encodedPath = path + "?" + encodedQueryParams;
|
||||
}
|
||||
|
||||
HttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.valueOf(apiRequest.getMethod()), encodedPath, content);
|
||||
|
||||
request.headers().set("Host", host);
|
||||
request.headers().set("Connection", HttpHeaderValues.CLOSE);
|
||||
|
||||
Reference in New Issue
Block a user