crossroads

Git mirror of https://crossroads.e-tunity.com/
git clone git://git.finwo.net/app/crossroads
Log | Files | Refs | LICENSE

findheader.cc (729B)


      1 #include "httpbuffer"
      2 
      3 unsigned Httpbuffer::findheader(string h) {
      4     PROFILE("Httpbuffer::findheader");
      5 
      6     // No headers in here yet? Don't process.
      7     if (!headersreceived())
      8 	return 0;
      9 
     10     // We must have a first HTTP line, else we don't have headers
     11     if (!firstline().length())
     12 	return 0;
     13 
     14     // Scan until bodystart (which is set in headersreceived()).
     15     // Used to scan until bufsz() but that's not right, thanks Maxim P.
     16     for (unsigned int i = 1; i < bodystart; /* incremented below */) {
     17 	// At header?
     18 	if (!strncmp(bufdata() + i, h.c_str(), h.size()))
     19 	    return i;
     20 
     21 	// No, advance beyond \n or fail
     22 	if (! (i = charfind('\n', i)) )
     23 	    return 0;
     24 	i++;
     25     }
     26 
     27     // Avoiding warnings:
     28     return 0;
     29 }