rename Http:put() to Http:post() and add a separate Http:put()
This commit is contained in:
@@ -73,6 +73,7 @@ Http & Http::begin()
|
||||
debug_info = nullptr;
|
||||
follow_location = true;
|
||||
verify_ssl_cert = true;
|
||||
use_post_method = true;
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -281,7 +282,7 @@ bool Http::get(const pt::WTextStream & url, pt::WTextStream & out, bool clear_st
|
||||
}
|
||||
|
||||
|
||||
bool Http::put(const wchar_t * url, const std::string & in, pt::WTextStream & out, bool clear_stream)
|
||||
bool Http::post_put(const wchar_t * url, const std::string & in, pt::WTextStream & out, bool clear_stream)
|
||||
{
|
||||
std::string url_ascii;
|
||||
pt::TextStream out_stream;
|
||||
@@ -300,9 +301,40 @@ bool Http::put(const wchar_t * url, const std::string & in, pt::WTextStream & ou
|
||||
}
|
||||
|
||||
|
||||
bool Http::post(const wchar_t * url, const std::string & in, pt::WTextStream & out, bool clear_stream)
|
||||
{
|
||||
use_post_method = true;
|
||||
return post_put(url, in, out, clear_stream);
|
||||
}
|
||||
|
||||
|
||||
bool Http::post(const std::wstring & url, const std::string & in, pt::WTextStream & out, bool clear_stream)
|
||||
{
|
||||
use_post_method = true;
|
||||
return post_put(url.c_str(), in, out, clear_stream);
|
||||
}
|
||||
|
||||
|
||||
bool Http::post(const wchar_t * url, pt::WTextStream & in, pt::WTextStream & out, bool clear_stream)
|
||||
{
|
||||
std::string in_ascii;
|
||||
in.to_str(in_ascii);
|
||||
use_post_method = true;
|
||||
return post_put(url, in_ascii, out, clear_stream);
|
||||
}
|
||||
|
||||
|
||||
bool Http::put(const wchar_t * url, const std::string & in, pt::WTextStream & out, bool clear_stream)
|
||||
{
|
||||
use_post_method = false;
|
||||
return post_put(url, in, out, clear_stream);
|
||||
}
|
||||
|
||||
|
||||
bool Http::put(const std::wstring & url, const std::string & in, pt::WTextStream & out, bool clear_stream)
|
||||
{
|
||||
return put(url.c_str(), in, out, clear_stream);
|
||||
use_post_method = false;
|
||||
return post_put(url.c_str(), in, out, clear_stream);
|
||||
}
|
||||
|
||||
|
||||
@@ -310,8 +342,8 @@ bool Http::put(const wchar_t * url, pt::WTextStream & in, pt::WTextStream & out,
|
||||
{
|
||||
std::string in_ascii;
|
||||
in.to_str(in_ascii);
|
||||
|
||||
return put(url, in_ascii, out, clear_stream);
|
||||
use_post_method = false;
|
||||
return post_put(url, in_ascii, out, clear_stream);
|
||||
}
|
||||
|
||||
|
||||
@@ -488,7 +520,11 @@ bool Http::fetch_internal(const char * url, const std::string * in, pt::TextStre
|
||||
curl_easy_setopt(curl, CURLOPT_READDATA, this);
|
||||
curl_easy_setopt(curl, CURLOPT_SEEKFUNCTION, fetch_seek_function);
|
||||
curl_easy_setopt(curl, CURLOPT_SEEKDATA, this);
|
||||
curl_easy_setopt(curl, CURLOPT_POST, 1);
|
||||
|
||||
if( use_post_method )
|
||||
curl_easy_setopt(curl, CURLOPT_POST, 1);
|
||||
else
|
||||
curl_easy_setopt(curl, CURLOPT_PUT, 1);
|
||||
|
||||
curl_off_t size = read_function_input->size();
|
||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE_LARGE, size);
|
||||
|
||||
Reference in New Issue
Block a user