title: How to determine the length of "Content-Length: " in HTTP packet
body: <p>I'm writing code for an http server on an embedded target.  I want to parse the raw HTTP packet I am receiving for its' content length.  My problem arises from the fact that I don't know how many bytes the content length is.  For example, <br/><br/>
  //Content-Length is 4 characters<br/>
  Content-Length: 1000</p>
  
  <p>//Content-Length is 2 characters<br/>
  Content-Length: 20</p>
  
  <p>My code is:</p>
  
  <pre><code>(buf is a char array with the contents of the http data, pLength is a char *)
  pLength = strstr(buf, lenTok);
  //advance pointer past "Content-Length: " to point to data
  if (pLength != NULL) 
      pLength = (pLength + 16);
  int length = 0;
  for (int i = 0; i &lt; /*length of Content-Length:*/; i++)
  {
      length = length * 10;
      length = length + (pLength[i] - '0');
  }
  </code></pre>
  
  <p>I know my code works because for now I have put a hard coded value in the loop iterator condition.  I just need to be able to determine it at run time.</p>
  
  <p>EDIT: Would it be safe to keep reading characters until \r is found?</p>