MCPcopy Create free account
hub / github.com/aria2/aria2 / parse

Method parse

src/HttpHeaderProcessor.cc:140–464  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

138} // namespace
139
140bool HttpHeaderProcessor::parse(const unsigned char* data, size_t length)
141{
142 size_t i;
143 lastBytesProcessed_ = 0;
144 for (i = 0; i < length; ++i) {
145 unsigned char c = data[i];
146 switch (state_) {
147 case PREV_METHOD:
148 if (util::isLws(c) || util::isCRLF(c)) {
149 throw DL_ABORT_EX("Bad Request-Line: missing method");
150 }
151
152 i = getToken(buf_, data, length, i);
153 state_ = METHOD;
154 break;
155
156 case METHOD:
157 if (util::isLws(c)) {
158 result_->setMethod(buf_);
159 buf_.clear();
160 state_ = PREV_PATH;
161 break;
162 }
163
164 if (util::isCRLF(c)) {
165 throw DL_ABORT_EX("Bad Request-Line: missing request-target");
166 }
167
168 i = getToken(buf_, data, length, i);
169 break;
170
171 case PREV_PATH:
172 if (util::isCRLF(c)) {
173 throw DL_ABORT_EX("Bad Request-Line: missing request-target");
174 }
175
176 if (util::isLws(c)) {
177 break;
178 }
179
180 i = getToken(buf_, data, length, i);
181 state_ = PATH;
182 break;
183
184 case PATH:
185 if (util::isLws(c)) {
186 result_->setRequestPath(buf_);
187 buf_.clear();
188 state_ = PREV_REQ_VERSION;
189 break;
190 }
191
192 if (util::isCRLF(c)) {
193 throw DL_ABORT_EX("Bad Request-Line: missing HTTP-version");
194 }
195
196 i = getToken(buf_, data, length, i);
197 break;

Callers

nothing calls this directly

Calls 15

isLwsFunction · 0.85
isCRLFFunction · 0.85
getTokenFunction · 0.85
isNumberFunction · 0.85
getTextFunction · 0.85
stripFunction · 0.85
getFieldNameTokenFunction · 0.85
lowercaseFunction · 0.85
idInterestingHeaderFunction · 0.85
ignoreTextFunction · 0.85
setStatusCodeMethod · 0.80
setReasonPhraseMethod · 0.80

Tested by

no test coverage detected