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

Function DoDoRequest

engine/dlib/src/dlib/http_client.cpp:1005–1125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1003 }
1004
1005 static Result DoDoRequest(HClient client, Response& response, const char* path, const char* method)
1006 {
1007 dmSocket::Result sock_res;
1008
1009 sock_res = SendRequest(client, &response, path, method);
1010
1011 bool method_is_head = strcmp(method, "HEAD") == 0;
1012 bool method_is_connect = strcmp(method, "CONNECT") == 0;
1013
1014#if defined(DM_NO_HTTP_CACHE)
1015 (void) method_is_head;
1016 (void) method_is_connect;
1017#endif
1018
1019 if (sock_res != dmSocket::RESULT_OK)
1020 {
1021 return RESULT_SOCKET_ERROR;
1022 }
1023
1024 Result r = RecvAndParseHeaders(client, &response);
1025 if (r != RESULT_OK)
1026 {
1027 response.m_CloseConnection = 1;
1028 return r;
1029 }
1030
1031 if (response.m_Status == 204 /* No Content*/)
1032 {
1033 // assume content length is zero. No need to complain if an invalid response non empty content is received.
1034 response.m_ContentLength = 0;
1035 }
1036
1037 if (response.m_Chunked)
1038 {
1039 // Ok
1040 }
1041 else if (response.m_ContentLength == -1 && response.m_Status != 304)
1042 {
1043 // When not chunked (and not 304) we used to require Content-Length attribute to be set
1044 // but changed to support this behavior in order to be compatible with old/exotic web-servers.
1045 // The connection is however closed as keep-alive isn't possible for this case.
1046 response.m_CloseConnection = 1;
1047 }
1048
1049 if (response.m_Status == 304 /* NOT MODIFIED */)
1050 {
1051 // Use cached version
1052 if (response.m_ContentLength == 0 || response.m_ContentLength == -1)
1053 {
1054#if !defined(DM_NO_HTTP_CACHE)
1055 if (!client->m_IgnoreCache && client->m_HttpCache)
1056 {
1057 r = HandleCached(client, path, &response, method_is_head);
1058 }
1059#endif
1060 response.m_TotalReceived = 0;
1061 }
1062 else

Callers 1

DoRequestFunction · 0.85

Calls 8

SendRequestFunction · 0.85
RecvAndParseHeadersFunction · 0.85
HandleCachedFunction · 0.85
HandleResponseFunction · 0.85
BeginFunction · 0.70
SetErrorFunction · 0.70
EndFunction · 0.70
MaxFunction · 0.50

Tested by

no test coverage detected