| 1062 | } |
| 1063 | |
| 1064 | int DoraXrtHttpExecuteStream( |
| 1065 | const char* method, |
| 1066 | const char* url, |
| 1067 | const char* const* headerNames, |
| 1068 | const char* const* headerValues, |
| 1069 | size_t headerCount, |
| 1070 | const void* body, |
| 1071 | size_t bodyLen, |
| 1072 | unsigned int timeoutMs, |
| 1073 | int verifyPeer, |
| 1074 | DoraXrtHttpShouldCancel shouldCancel, |
| 1075 | void* cancelUserData, |
| 1076 | DoraXrtHttpStreamHandler onChunk, |
| 1077 | void* streamUserData, |
| 1078 | int* statusCode) { |
| 1079 | char currentUrl[XHTTP_URL_CAP]; |
| 1080 | char nextUrl[XHTTP_URL_CAP]; |
| 1081 | char location[XHTTP_URL_CAP]; |
| 1082 | const char* currentMethod = method; |
| 1083 | const void* currentBody = body; |
| 1084 | size_t currentBodyLen = bodyLen; |
| 1085 | xnet_result status = XRT_NET_ERROR; |
| 1086 | |
| 1087 | if (statusCode) { |
| 1088 | *statusCode = 0; |
| 1089 | } |
| 1090 | if (!method || !url) { |
| 1091 | return XRT_NET_ERROR; |
| 1092 | } |
| 1093 | if (!DoraXrtHttpAttachRuntimeThread()) { |
| 1094 | return XRT_NET_ERROR; |
| 1095 | } |
| 1096 | if (strlen(url) >= sizeof(currentUrl)) { |
| 1097 | xrtThreadDetachCurrent(); |
| 1098 | return XRT_NET_ERROR; |
| 1099 | } |
| 1100 | strcpy(currentUrl, url); |
| 1101 | |
| 1102 | for (int redirect = 0; redirect <= DORA_XRT_HTTP_MAX_REDIRECTS; ++redirect) { |
| 1103 | int currentStatusCode = 0; |
| 1104 | status = DoraXrtHttpExecuteStreamOnce( |
| 1105 | currentMethod, |
| 1106 | currentUrl, |
| 1107 | headerNames, |
| 1108 | headerValues, |
| 1109 | headerCount, |
| 1110 | currentBody, |
| 1111 | currentBodyLen, |
| 1112 | timeoutMs, |
| 1113 | verifyPeer, |
| 1114 | shouldCancel, |
| 1115 | cancelUserData, |
| 1116 | onChunk, |
| 1117 | streamUserData, |
| 1118 | ¤tStatusCode, |
| 1119 | location, |
| 1120 | sizeof(location)); |
| 1121 | if (statusCode) { |
no test coverage detected