setheader.cc (465B)
1 #include "httpbuffer" 2 3 void Httpbuffer::setheader (string const &var, string const &val) { 4 PROFILE("Httpbuffer::setheader"); 5 6 if (!headersreceived()) 7 return; 8 9 string myvar = var; 10 11 if (myvar[myvar.size() - 1] != ':') 12 myvar += ':'; 13 14 // Find position beyond first \n 15 unsigned i; 16 if (! (i = charfind('\n')) ) 17 return; 18 19 // Poke in the header. 20 string h; 21 h = myvar + ' ' + val + "\r\n"; 22 insertat(i + 1, h.c_str()); 23 }