MCPcopy Create free account
hub / github.com/alibaba/CicadaPlayer / setSourceConfig

Method setSourceConfig

framework/data_source/curl/CURLConnection.cpp:57–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

55}
56
57void Cicada::CURLConnection::setSourceConfig(Cicada::IDataSource::SourceConfig *pConfig)
58{
59 mPConfig = pConfig;
60
61 if (mPConfig) {
62 so_rcv_size = pConfig->so_rcv_size;
63 string &http_proxy = pConfig->http_proxy;
64
65 if (!http_proxy.empty()) {
66 CURL_LOGD("http_proxy is %s\n", http_proxy.c_str());
67
68 if (http_proxy == "never") {
69 curl_easy_setopt(mHttp_handle, CURLOPT_PROXY, NULL);
70 } else {
71 curl_easy_setopt(mHttp_handle, CURLOPT_PROXY, http_proxy.c_str());
72 }
73 }
74
75 string &refer = pConfig->refer;
76
77 if (!refer.empty()) {
78 CURL_LOGD("refer is %s\n", refer.c_str());
79 curl_easy_setopt(mHttp_handle, CURLOPT_REFERER, refer.c_str());
80 }
81
82 string &userAgent = pConfig->userAgent;
83
84 if (!userAgent.empty()) {
85 CURL_LOGD("userAgent is %s\n", userAgent.c_str());
86 curl_easy_setopt(mHttp_handle, CURLOPT_USERAGENT, userAgent.c_str());
87 }
88
89 if (pConfig->low_speed_limit && pConfig->low_speed_time_ms) {
90 CURL_LOGD("set low_speed_limit to %d\n", pConfig->low_speed_limit);
91 CURL_LOGD("set low_speed_time to %d(ms)\n", pConfig->low_speed_time_ms);
92 curl_easy_setopt(mHttp_handle, CURLOPT_LOW_SPEED_LIMIT, (long) pConfig->low_speed_limit);
93 curl_easy_setopt(mHttp_handle, CURLOPT_LOW_SPEED_TIME, (long) pConfig->low_speed_time_ms / 1000);
94 }
95
96 if (pConfig->connect_time_out_ms > 0) {
97 CURL_LOGD("set connect_time to %d(ms)\n", pConfig->connect_time_out_ms);
98 curl_easy_setopt(mHttp_handle, CURLOPT_CONNECTTIMEOUT, (long) pConfig->connect_time_out_ms / 1000);
99 }
100
101 switch (pConfig->resolveType) {
102 case IDataSource::SourceConfig::IpResolveV4:
103 curl_easy_setopt(mHttp_handle, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
104 break;
105 case IDataSource::SourceConfig::IpResolveV6:
106 curl_easy_setopt(mHttp_handle, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V6);
107 break;
108
109 default:
110 break;
111 }
112 }
113}
114

Callers 1

initConnectionMethod · 0.45

Calls 1

emptyMethod · 0.45

Tested by

no test coverage detected