MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / DoraXrtHttpExecute

Function DoraXrtHttpExecute

Source/Http/XrtHttpClient.c:984–1062  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

982}
983
984int DoraXrtHttpExecute(
985 const char* method,
986 const char* url,
987 const char* const* headerNames,
988 const char* const* headerValues,
989 size_t headerCount,
990 const void* body,
991 size_t bodyLen,
992 unsigned int timeoutMs,
993 int verifyPeer,
994 DoraXrtHttpShouldCancel shouldCancel,
995 void* userData,
996 DoraXrtHttpResponse* response) {
997 char currentUrl[XHTTP_URL_CAP];
998 char nextUrl[XHTTP_URL_CAP];
999 const char* currentMethod = method;
1000 const void* currentBody = body;
1001 size_t currentBodyLen = bodyLen;
1002 int netStatus = XRT_NET_ERROR;
1003
1004 if (!response || !method || !url) {
1005 return XRT_NET_ERROR;
1006 }
1007 if (!DoraXrtHttpAttachRuntimeThread()) {
1008 return XRT_NET_ERROR;
1009 }
1010 memset(response, 0, sizeof(*response));
1011 response->netStatus = XRT_NET_ERROR;
1012 if (strlen(url) >= sizeof(currentUrl)) {
1013 xrtThreadDetachCurrent();
1014 return XRT_NET_ERROR;
1015 }
1016 strcpy(currentUrl, url);
1017
1018 for (int redirect = 0; redirect <= DORA_XRT_HTTP_MAX_REDIRECTS; ++redirect) {
1019 xhttpresponse* xrtResponse = DoraXrtHttpExecuteOnce(
1020 currentMethod,
1021 currentUrl,
1022 headerNames,
1023 headerValues,
1024 headerCount,
1025 currentBody,
1026 currentBodyLen,
1027 timeoutMs,
1028 verifyPeer,
1029 shouldCancel,
1030 userData,
1031 &netStatus);
1032 response->netStatus = netStatus;
1033 if (netStatus != XRT_NET_OK || !xrtResponse) {
1034 xrtThreadDetachCurrent();
1035 return netStatus;
1036 }
1037 if (DoraXrtHttpIsRedirect(xrtResponse->iStatusCode)) {
1038 const char* location = xrtHttpResponseHeader(xrtResponse, "Location");
1039 if (location && DoraXrtHttpResolveRedirect(currentUrl, location, nextUrl, sizeof(nextUrl))) {
1040 strcpy(currentUrl, nextUrl);
1041 if (xrtResponse->iStatusCode == 303u) {

Callers 2

postAsyncMethod · 0.85
getAsyncMethod · 0.85

Calls 8

strlenFunction · 0.85
strcpyFunction · 0.85
DoraXrtHttpExecuteOnceFunction · 0.85
DoraXrtHttpIsRedirectFunction · 0.85
DoraXrtHttpCopyResponseFunction · 0.85
memsetFunction · 0.50

Tested by

no test coverage detected