MCPcopy Create free account
hub / github.com/defold/defold / SetUp

Method SetUp

engine/dlib/src/test/test_httpclient.cpp:223–292  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

221 }
222
223 void SetUp() override
224 {
225 m_Client = 0;
226
227 char url[1024];
228 strcpy(url, GetParam());
229
230 bool is_https = strstr(url, "https://") != 0;
231
232 char* host = strstr(url, NAME_SERVER_IP);
233 if (host != 0) {
234 char urlcopy[1024];
235 // poor mans replace
236 const char* rest = host + strlen(NAME_SERVER_IP);
237 dmSnPrintf(urlcopy, sizeof(urlcopy), "%s://%s%s", is_https?"https":"http", SERVER_IP, rest);
238 memcpy(url, urlcopy, sizeof(url));
239 }
240
241 char* portstr = strrchr(url, ':');
242 ++portstr;
243
244 int port = -1;
245 if( strcmp(NAME_SOCKET, portstr) == 0 )
246 {
247 port = g_HttpPort;
248 }
249 else if( strcmp(NAME_SOCKET_TLS, portstr) == 0 )
250 {
251 port = g_HttpPortTLS;
252 }
253 else if( strcmp(NAME_SOCKET_TLS12, portstr) == 0 )
254 {
255 port = g_HttpPortTLS12;
256 }
257 else if( strcmp(NAME_SOCKET_TLS13, portstr) == 0 )
258 {
259 port = g_HttpPortTLS13;
260 }
261 else if( strcmp(NAME_SOCKET_TLS_TEST, portstr) == 0 )
262 {
263 port = g_HttpPortTLSTest;
264 }
265 else {
266 // no port
267 }
268
269 if (port != -1)
270 {
271 dmSnPrintf(portstr, sizeof(url) - (portstr - url), "%d", port);
272 }
273
274
275 dmURI::Result parse_r = dmURI::Parse(url, &m_URI);
276 ASSERT_EQ(dmURI::RESULT_OK, parse_r);
277
278 SetupTestData();
279
280 dmHttpClient::NewParams params;

Callers

nothing calls this directly

Calls 3

dmSnPrintfFunction · 0.85
ParseFunction · 0.50
NewFunction · 0.50

Tested by

no test coverage detected