File: setheader.cc

package info (click to toggle)
crossroads 2.65-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 2,664 kB
  • ctags: 355
  • sloc: cpp: 4,212; perl: 1,658; xml: 269; makefile: 186; sh: 46
file content (23 lines) | stat: -rw-r--r-- 465 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include "httpbuffer"

void Httpbuffer::setheader (string const &var, string const &val) {
    PROFILE("Httpbuffer::setheader");
    
    if (!headersreceived())
	return;
	
    string myvar = var;
    
    if (myvar[myvar.size() - 1] != ':')
	myvar += ':';

    // Find position beyond first \n
    unsigned i;
    if (! (i = charfind('\n')) )
	return;

    // Poke in the header.
    string h;
    h = myvar + ' ' + val + "\r\n";
    insertat(i + 1, h.c_str());
}