// Copyright 2018 Mobvoi Inc. All Rights Reserved. // Author: ybtang@mobvoi.com (Yanbin Tang) #ifndef SDS_SERVICES_ONLINE_TTS_HTTP_CHUNK_CLIENT_H_ #define SDS_SERVICES_ONLINE_TTS_HTTP_CHUNK_CLIENT_H_ //#include "third_party/curl/curl.h" //#include "mobvoi/base/basictypes.h" //#include "mobvoi/base/compat.h" //#include "mobvoi/base/log.h" #include #include "basictypes.h" #include "compat.h" #include "log.h" namespace mobvoi { namespace sds { typedef SDK_DLL_API std::map UrlQueryParams; typedef SDK_DLL_API size_t(*WriteCallback)(void*, size_t, size_t, void*); //typedef SDK_DLL_API size_t(*WriteCallback2)(void*, size_t, size_t, void*); typedef SDK_DLL_API size_t(*WriteCallback2)(void*, size_t, size_t, FILE *); // //size_t my_write_func2(void* ptr, // size_t size, // size_t nmemb, // void* userdata) { class SDK_DLL_API HttpChunkClient { public: HttpChunkClient(); ~HttpChunkClient(); void Reset(); bool FetchUrl(const std::string& url); void StopTransfer(); int response_code() const { return response_code_; } // Sets header. void AddHeader(const std::string& key, const std::string& value); // Sets options. void SetConnectTimeout(int time_ms); void SetFetchTimeout(int time_ms); void SetUserAgent(const char* user_agent); void SetWriteCallback(void* buffer, WriteCallback callback); void SetWriteCallback2(FILE *outfile, WriteCallback2 callback); void SetBindNetwork(const std::string& interface1, const std::string& ip); private: long response_code_; // NOLINT CURL* curl_handle_; struct curl_slist* header_list_; //DISALLOW_COPY_AND_ASSIGN(HttpChunkClient); }; SDK_DLL_API std::string CreateUrl(const std::string& protocol, const std::string& host, const std::string& uri, const UrlQueryParams& params); } // namespace sds } // namespace mobvoi #endif // SDS_SERVICES_ONLINE_TTS_HTTP_CHUNK_CLIENT_H_