MCPcopy Create free account
hub / github.com/F-Stack/f-stack / soparsehttpvers

Function soparsehttpvers

freebsd/netinet/accf_http.c:199–274  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

197}
198
199static int
200soparsehttpvers(struct socket *so, void *arg, int waitflag)
201{
202 struct mbuf *m, *n;
203 int i, cc, spaces, inspaces;
204
205 if ((so->so_rcv.sb_state & SBS_CANTRCVMORE) != 0 || sbfull(&so->so_rcv))
206 goto fallout;
207
208 m = so->so_rcv.sb_mb;
209 cc = sbavail(&so->so_rcv);
210 inspaces = spaces = 0;
211 for (m = so->so_rcv.sb_mb; m; m = n) {
212 n = m->m_nextpkt;
213 for (; m; m = m->m_next) {
214 for (i = 0; i < m->m_len; i++, cc--) {
215 switch (*(mtod(m, char *) + i)) {
216 case ' ':
217 /* tabs? '\t' */
218 if (!inspaces) {
219 spaces++;
220 inspaces = 1;
221 }
222 break;
223 case '\r':
224 case '\n':
225 DPRINT("newline");
226 goto fallout;
227 default:
228 if (spaces != 2) {
229 inspaces = 0;
230 break;
231 }
232
233 /*
234 * if we don't have enough characters
235 * left (cc < sizeof("HTTP/1.0") - 1)
236 * then see if the remaining ones
237 * are a request we can parse.
238 */
239 if (cc < sizeof("HTTP/1.0") - 1) {
240 if (mbufstrncmp(m, n, i, cc,
241 "HTTP/1.") == 1) {
242 DPRINT("ok");
243 goto readmore;
244 } else {
245 DPRINT("bad");
246 goto fallout;
247 }
248 } else if (
249 mbufstrcmp(m, n, i, "HTTP/1.0") ||
250 mbufstrcmp(m, n, i, "HTTP/1.1")) {
251 DPRINT("ok");
252 return (soishttpconnected(so,
253 arg, waitflag));
254 } else {
255 DPRINT("bad");
256 goto fallout;

Callers 1

sohashttpgetFunction · 0.85

Calls 6

sbfullFunction · 0.85
mbufstrncmpFunction · 0.85
mbufstrcmpFunction · 0.85
soishttpconnectedFunction · 0.85
soupcall_setFunction · 0.85
sbavailFunction · 0.50

Tested by

no test coverage detected