MCPcopy Create free account
hub / github.com/cuberite/cuberite / OnPartHeader

Method OnPartHeader

src/HTTPServer/HTTPFormParser.cpp:201–240  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

199
200
201void cHTTPFormParser::OnPartHeader(const AString & a_Key, const AString & a_Value)
202{
203 if (NoCaseCompare(a_Key, "Content-Disposition") == 0)
204 {
205 size_t len = a_Value.size();
206 size_t ParamsStart = AString::npos;
207 for (size_t i = 0; i < len; ++i)
208 {
209 if (a_Value[i] > ' ')
210 {
211 if (strncmp(a_Value.c_str() + i, "form-data", 9) != 0)
212 {
213 // Content disposition is not "form-data", mark the whole form invalid
214 m_IsValid = false;
215 return;
216 }
217 ParamsStart = a_Value.find(';', i + 9);
218 break;
219 }
220 }
221 if (ParamsStart == AString::npos)
222 {
223 // There is data missing in the Content-Disposition field, mark the whole form invalid:
224 m_IsValid = false;
225 return;
226 }
227
228 // Parse the field name and optional filename from this header:
229 cNameValueParser Parser(a_Value.data() + ParamsStart, a_Value.size() - ParamsStart);
230 Parser.Finish();
231 m_CurrentPartName = Parser["name"];
232 if (!Parser.IsValid() || m_CurrentPartName.empty())
233 {
234 // The required parameter "name" is missing, mark the whole form invalid:
235 m_IsValid = false;
236 return;
237 }
238 m_CurrentPartFileName = Parser["filename"];
239 }
240}
241
242
243

Callers

nothing calls this directly

Calls 6

NoCaseCompareFunction · 0.85
sizeMethod · 0.80
c_strMethod · 0.80
emptyMethod · 0.80
FinishMethod · 0.45
IsValidMethod · 0.45

Tested by

no test coverage detected