load tester beta
This commit is contained in:
@@ -52,9 +52,7 @@ public class HttpHandler extends SimpleChannelInboundHandler<FullHttpResponse> {
|
||||
public List<ApiRequestKeyValueDTO> convertHttpHeadersToList(HttpHeaders headers) {
|
||||
List<ApiRequestKeyValueDTO> headerList = new ArrayList<>();
|
||||
for (Map.Entry<String, String> entry : headers.entries()) {
|
||||
ApiRequestKeyValueDTO header = new ApiRequestKeyValueDTO();
|
||||
header.setKey(entry.getKey());
|
||||
header.setValue(entry.getValue());
|
||||
ApiRequestKeyValueDTO header = new ApiRequestKeyValueDTO(true, entry.getKey(), entry.getValue());
|
||||
headerList.add(header);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@ import io.netty.handler.ssl.SslContextBuilder;
|
||||
import io.netty.handler.ssl.util.InsecureTrustManagerFactory;
|
||||
import io.netty.util.CharsetUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -29,12 +31,12 @@ import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Service
|
||||
public class NettyApiClient {
|
||||
private static final Logger logger = LoggerFactory.getLogger(NettyApiClient.class);
|
||||
|
||||
@Autowired
|
||||
ServerRepository serverRepository;
|
||||
|
||||
public CompletableFuture<ApiResponse> handleRequest(ApiRequestDTO originalRequest) {
|
||||
ApiRequestDTO apiRequest = originalRequest;
|
||||
public CompletableFuture<ApiResponse> handleRequest(ApiRequestDTO apiRequest) {
|
||||
Server server = serverRepository.findById(apiRequest.getServer()).orElseThrow(() -> new ServerNotFoundException("Server not found"));
|
||||
String host = server.getHostname();
|
||||
int port = server.getPort();
|
||||
@@ -92,6 +94,8 @@ public class NettyApiClient {
|
||||
request.headers().add(customHeaders);
|
||||
}
|
||||
|
||||
apiRequest.setSentBytes(request.toString().length());
|
||||
|
||||
ch.writeAndFlush(request);
|
||||
ch.closeFuture().sync();
|
||||
} catch (Exception e) {
|
||||
|
||||
Reference in New Issue
Block a user