Skip to content

Commit

Permalink
Fix auth on minimal requests
Browse files Browse the repository at this point in the history
  • Loading branch information
suchmememanyskill committed Jul 14, 2024
1 parent 5d2571e commit 04d8902
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion CYD-Klipper/src/core/data_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ void fetch_printer_data_minimal()

delay(10);
HTTPClient client;
configure_http_client(client, get_full_url("/printer/objects/query?webhooks&print_stats&virtual_sdcard", config), true, 1000);
configure_http_client(client, get_full_url("/printer/objects/query?webhooks&print_stats&virtual_sdcard", config), true, 1000, config);
freeze_request_thread();

int httpCode = client.GET();
Expand Down
13 changes: 8 additions & 5 deletions CYD-Klipper/src/core/http_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@

String get_full_url(String url_part, PRINTER_CONFIG * config)
{
if (config == NULL){
config = get_current_printer_config();
}

return "http://" + String(config->klipper_host) + ":" + String(config->klipper_port) + url_part;
}

String get_full_url(String url_part)
void configure_http_client(HTTPClient &client, String url, bool stream, int timeout, PRINTER_CONFIG * config)
{
return "http://" + String(get_current_printer_config()->klipper_host) + ":" + String(get_current_printer_config()->klipper_port) + url_part;
}
if (config == NULL){
config = get_current_printer_config();
}

void configure_http_client(HTTPClient &client, String url, bool stream, int timeout)
{
if (stream){
client.useHTTP10(true);
}
Expand Down
7 changes: 2 additions & 5 deletions CYD-Klipper/src/core/http_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@
#include <HTTPClient.h>
#include "../conf/global_config.h"

String get_full_url(String url_part);
String get_full_url(String url_part, PRINTER_CONFIG * config);

void configure_http_client(HTTPClient &client, String url, bool stream = true, int timeout = 1000);
String get_full_url(String url_part, PRINTER_CONFIG * config = NULL);
void configure_http_client(HTTPClient &client, String url, bool stream = true, int timeout = 1000, PRINTER_CONFIG * config = NULL);

#define SETUP_HTTP_CLIENT(url_part) HTTPClient client; configure_http_client(client, get_full_url(url_part));

#define SETUP_HTTP_CLIENT_FULL(url_part, stream, timeout) HTTPClient client; configure_http_client(client, get_full_url(url_part), stream, timeout);

0 comments on commit 04d8902

Please sign in to comment.