diff --git a/src/request-data.cpp b/src/request-data.cpp index a59b0cd..bdd7c98 100644 --- a/src/request-data.cpp +++ b/src/request-data.cpp @@ -276,11 +276,10 @@ struct request_data_handler_response request_data_handler(url_source_request_dat textStr.c_str()); // if one of the headers is Content-Type application/json, make sure the text is JSONified + std::regex header_regex("content-type", + std::regex_constants::icase); for (auto header : request_data->headers) { // check if the header is Content-Type case insensitive using regex - std::regex header_regex( - "content-type", - std::regex_constants::icase); if (std::regex_search(header.first, header_regex) && header.second == "application/json") { nlohmann::json tmp = text; diff --git a/src/ui/RequestBuilder.cpp b/src/ui/RequestBuilder.cpp index 75d96f9..10e4236 100644 --- a/src/ui/RequestBuilder.cpp +++ b/src/ui/RequestBuilder.cpp @@ -148,7 +148,7 @@ RequestBuilder::RequestBuilder(url_source_request_data *request_data, if (index == 1 || index == 2 || index == 3) { //OpenAI ui->methodComboBox->setCurrentIndex(1); - addHeaders({{"Content-Type", "application/json "}, + addHeaders({{"Content-Type", "application/json"}, {"Authorization", "Bearer $OPENAI_API_KEY"}}, ui->tableView_headers); } @@ -223,7 +223,7 @@ RequestBuilder::RequestBuilder(url_source_request_data *request_data, /* --------------- 11Labs TTS --------------- */ /* ------------------------------------------- */ ui->methodComboBox->setCurrentIndex(1); - addHeaders({{"Content-Type", "application/json "}, + addHeaders({{"Content-Type", "application/json"}, {"Accept", "application/json"}, {"xi-api-key", "$XI_API_KEY"}}, ui->tableView_headers); @@ -254,7 +254,7 @@ RequestBuilder::RequestBuilder(url_source_request_data *request_data, ui->urlLineEdit->setText("https://api-free.deepl.com/v2/translate"); addHeaders( { - {"Content-Type", "application/json "}, + {"Content-Type", "application/json"}, {"Authorization", "DeepL-Auth-Key $yourAuthKey"}, }, ui->tableView_headers);