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

Function SendResponse

engine/script/src/http_service.cpp:218–248  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

216 }
217
218 static void SendResponse(const dmMessage::URL* requester, uintptr_t userdata1, uintptr_t userdata2, int status,
219 const char* headers, uint32_t headers_length,
220 const char* response, uint32_t response_length,
221 const char* url,
222 const char* filepath,
223 uint32_t range_start,
224 uint32_t range_end,
225 uint32_t document_size)
226 {
227 dmHttpDDF::HttpResponse resp;
228 resp.m_Status = status;
229 resp.m_HeadersLength = headers_length;
230 resp.m_ResponseLength = response_length;
231 resp.m_RangeStart = range_start;
232 resp.m_RangeEnd = range_end;
233 resp.m_DocumentSize = document_size;
234
235 resp.m_Headers = (uint64_t) malloc(headers_length);
236 memcpy((void*) resp.m_Headers, headers, headers_length);
237 resp.m_Response = (uint64_t) malloc(response_length);
238 memcpy((void*) resp.m_Response, response, response_length);
239 resp.m_Path = filepath;
240 resp.m_Url = url;
241
242 if (dmMessage::RESULT_OK != dmMessage::Post(0, requester, dmHttpDDF::HttpResponse::m_DDFHash, userdata1, userdata2, (uintptr_t) dmHttpDDF::HttpResponse::m_DDFDescriptor, &resp, sizeof(resp), MessageDestroyCallback) )
243 {
244 free((void*) resp.m_Headers);
245 free((void*) resp.m_Response);
246 dmLogWarning("Failed to return http-response. Requester deleted?");
247 }
248 }
249
250 static const char* FindHeader(Worker* worker, const char* header, char* buffer, uint32_t buffer_length)
251 {

Callers 1

HandleRequestFunction · 0.70

Calls 3

mallocFunction · 0.85
freeFunction · 0.85
PostFunction · 0.50

Tested by

no test coverage detected