#14 -- Fix code

This commit is contained in:
Anton Romanov 2025-03-20 14:24:48 +04:00
parent 11c4071b68
commit 9a12181ccf

View File

@ -1,7 +1,5 @@
package ru.ulstu.http;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.web.reactive.function.client.WebClient;
@ -15,51 +13,16 @@ import java.util.Base64;
import java.util.List;
public class HttpService {
private final Logger log = LoggerFactory.getLogger(HttpService.class);
private final WebClient client = getWebClient();
private final static String USER_NAME = "admin";
private final static String PASSWORD = "admin";
//private final MultiValueMap<String, String> myCookies = new LinkedMultiValueMap<String, String>();
public WebClient getWebClient() {
final int size = 16 * 1024 * 1024 * 10;
/*final ExchangeStrategies strategies = ExchangeStrategies.builder()
.codecs(codecs -> codecs.defaultCodecs().maxInMemorySize(size))
.build();*/
return WebClient.builder()
//.exchangeStrategies(strategies)
.defaultHeader(HttpHeaders.AUTHORIZATION, "Basic " +
Base64.getEncoder().encodeToString((USER_NAME + ":" + PASSWORD).getBytes()))
.build();
}
// private void auth() {
// try {
// client
// .get()
// .uri(AUTH_URL)
// .headers(headers -> headers.setBasicAuth(USER_NAME, PASSWORD))
// .header("IBSession", "start")
// .exchange()
// .subscribe(r ->
// {
// System.out.println("get cookies");
// for (String key : r.cookies().keySet()) {
// myCookies.put(key, List.of(r.cookies().get(key).get(0).getValue()));
// }
// }
// );
// System.out.println("start waiting");
// Thread.sleep(1000);
// System.out.println("stop waiting");
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// public String getWithAuth(int yearStart, int yearEnd) {
// auth();
// return get(yearStart, yearEnd);
// }
public List<OutputValue> post(String url, FuzzyRuleDataDto requestBody) {
List<OutputValue> result = new ArrayList<>();