ithewei 3 лет назад
Родитель
Сommit
0531daebc2
4 измененных файлов с 7 добавлено и 7 удалено
  1. 2 2
      http/client/axios.h
  2. 3 3
      http/client/http_client.cpp
  3. 1 1
      http/client/http_client.h
  4. 1 1
      http/client/requests.h

+ 2 - 2
http/client/axios.h

@@ -180,11 +180,11 @@ HV_INLINE Response Delete(const char* url, const char* req_str = nullptr) {
 // async
 HV_INLINE int axios(const json& jreq, ResponseCallback resp_cb) {
     auto req = newRequestFromJson(jreq);
-    return req ? requests::async(req, resp_cb) : -1;
+    return req ? requests::async(req, std::move(resp_cb)) : -1;
 }
 
 HV_INLINE int axios(const char* req_str, ResponseCallback resp_cb) {
-    return axios(json::parse(req_str), resp_cb);
+    return axios(json::parse(req_str), std::move(resp_cb));
 }
 
 }

+ 3 - 3
http/client/http_client.cpp

@@ -594,13 +594,13 @@ static int __http_client_send_async(http_client_t* cli, HttpRequestPtr req, Http
         cli->mutex_.unlock();
     }
 
-    return cli->async_client_->send(req, resp_cb);
+    return cli->async_client_->send(req, std::move(resp_cb));
 }
 
 int http_client_send_async(http_client_t* cli, HttpRequestPtr req, HttpResponseCallback resp_cb) {
     if (!cli || !req) return ERR_NULL_POINTER;
     http_client_make_request(cli, req.get());
-    return __http_client_send_async(cli, req, resp_cb);
+    return __http_client_send_async(cli, req, std::move(resp_cb));
 }
 
 static http_client_t* __get_default_async_client();
@@ -632,5 +632,5 @@ int http_client_send_async(HttpRequestPtr req, HttpResponseCallback resp_cb) {
         req->timeout = DEFAULT_HTTP_TIMEOUT;
     }
 
-    return __http_client_send_async(__get_default_async_client(), req, resp_cb);
+    return __http_client_send_async(__get_default_async_client(), req, std::move(resp_cb));
 }

+ 1 - 1
http/client/http_client.h

@@ -131,7 +131,7 @@ public:
 
     // async
     int sendAsync(HttpRequestPtr req, HttpResponseCallback resp_cb = NULL) {
-        return http_client_send_async(_client, req, resp_cb);
+        return http_client_send_async(_client, req, std::move(resp_cb));
     }
 
     // close

+ 1 - 1
http/client/requests.h

@@ -108,7 +108,7 @@ HV_INLINE Response Delete(const char* url, const http_headers& headers = Default
 }
 
 HV_INLINE int async(Request req, ResponseCallback resp_cb) {
-    return http_client_send_async(req, resp_cb);
+    return http_client_send_async(req, std::move(resp_cb));
 }
 
 }