diff --git a/src/IO/http.cc b/src/IO/http.cc index f422bf6..92f74e3 100644 --- a/src/IO/http.cc +++ b/src/IO/http.cc @@ -356,26 +356,26 @@ static char *Http_get_referer(const DilloUrl *url) /** * Generate Content-Type header value for a POST query. */ -static Dstr *Http_make_content_type(const DilloUrl *url) +static std::string Http_make_content_type(const DilloUrl *url) { - Dstr *dstr; + std::string dstr; if (URL_FLAGS(url) & URL_MultipartEnc) { _MSG("submitting multipart/form-data!\n"); - dstr = dStr_new("multipart/form-data; boundary=\""); + dstr = "multipart/form-data; boundary=\""; if (URL_DATA(url).size() > 2) { /* boundary lines have "--" prepended. Skip that. */ const char *start = URL_DATA(url).c_str() + 2; const char *eol = strchr(start, '\r'); if (eol) - dStr_append_l(dstr, start, eol - start); + dstr+= std::string_view{ start, eol - start }; } else { /* Zero parts; arbitrary boundary */ - dStr_append_c(dstr, '0'); + dstr+= '0'; } - dStr_append_c(dstr,'"'); + dstr+= '"'; } else { - dstr = dStr_new("application/x-www-form-urlencoded"); + dstr = "application/x-www-form-urlencoded"; } return dstr; } @@ -420,7 +420,7 @@ static Dstr *Http_make_query_str(DilloWeb *web, bool_t use_proxy, bool_t use_tls auth = a_Auth_get_auth_str(url, request_uri->str); referer = Http_get_referer(url); if (URL_FLAGS(url) & URL_Post) { - Dstr *content_type = Http_make_content_type(url); + const auto content_type = Http_make_content_type(url); dStr_sprintfa( query, "POST %s HTTP/1.1\r\n" @@ -440,10 +440,9 @@ static Dstr *Http_make_query_str(DilloWeb *web, bool_t use_proxy, bool_t use_tls "\r\n", request_uri->str, URL_AUTHORITY(url), prefs.http_user_agent, accept_hdr_value, HTTP_Language_hdr, auth ? auth : "", - proxy_auth->str, referer, connection_hdr_val, content_type->str, + proxy_auth->str, referer, connection_hdr_val, content_type.c_str(), (long)URL_DATA(url).size(), cookies); dStr_append_l(query, URL_DATA(url).c_str(), URL_DATA(url).size()); - dStr_free(content_type, TRUE); } else { dStr_sprintfa( query,