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

Function HttpContent

engine/dlib/src/dlib/http_cache_verify.cpp:122–173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

120 }
121
122 static void HttpContent(dmHttpClient::HResponse, void* user_data, int status_code, const void* content_data, uint32_t content_data_size, int32_t content_length,
123 uint32_t range_start, uint32_t range_end, uint32_t document_size,
124 const char* method)
125 {
126 (void) method; // Unused
127
128 VerifyContext* verify_context = (VerifyContext*) user_data;
129
130 verify_context->m_HttpStatus = status_code;
131
132 if (status_code != 200)
133 {
134 return;
135 }
136
137 const char* content_current = (const char*) content_data;
138 const char* content_end = content_current + content_data_size;
139
140 char* buf_current = verify_context->m_BufferCurrent;
141 char* buf_end = verify_context->m_Buffer + BUFFER_SIZE;
142
143 while (content_current < content_end)
144 {
145 int c = *content_current;
146 if (c == '\n')
147 {
148 // New uri
149 // Terminate string, we have room for the extra '\0'
150 *buf_current = '\0';
151 dmHttpCache::SetVerified(verify_context->m_HttpCache, verify_context->m_Buffer, true);
152
153 // Reset buffer
154 buf_current = verify_context->m_Buffer;
155 }
156 else
157 {
158 if (buf_current < buf_end)
159 {
160 *buf_current = c;
161 buf_current++;
162 }
163 else
164 {
165 dmLogError("Http cache verification uri entry too long");
166 // We discard the character and "wait" for '\n'
167 }
168 }
169
170 ++content_current;
171 }
172 verify_context->m_BufferCurrent = buf_current;
173 }
174
175 Result VerifyCache(dmHttpCache::HCache cache, dmURI::Parts* uri, uint64_t max_age)
176 {

Callers

nothing calls this directly

Calls 1

SetVerifiedFunction · 0.70

Tested by

no test coverage detected