taskrambler  0.1.9
Web server and task management solution.
add_common_header.c File Reference
#include <sys/types.h>
#include "class.h"
#include "http/message.h"
#include "http/header.h"
#include "http/worker.h"
#include "hash.h"
#include "utils/memory.h"
#include "utils/http.h"
#include "config.h"
+ Include dependency graph for add_common_header.c:

Go to the source code of this file.

Functions

void httpWorkerAddCommonHeader (HttpWorker this)
 

Detailed Description

Author
Georg Hopp

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file add_common_header.c.

Function Documentation

void httpWorkerAddCommonHeader ( HttpWorker  this)

Definition at line 40 of file add_common_header.c.

References CSTRA, hashAdd(), httpMessageHasKeepAlive(), and rfc1123GmtNow().

Referenced by httpWorkerProcess().

41 {
42  char buffer[200];
43  size_t nbuf;
44 
45  if (httpMessageHasKeepAlive((HttpMessage)this->current_request)) {
46  hashAdd(this->current_response->header,
47  new(HttpHeader, CSTRA("Connection"), CSTRA("Keep-Alive")));
48  }
49  else {
50  hashAdd(this->current_response->header,
51  new(HttpHeader, CSTRA("Connection"), CSTRA("Close")));
52  }
53 
54  hashAdd(this->current_response->header,
55  new(HttpHeader, CSTRA("Server"), CSTRA(PACKAGE_STRING)));
56 
57  switch(((HttpResponse)this->current_response)->status) {
58  case 304:
59  break;
60 
61  default:
62  nbuf = sprintf(buffer, "%d", this->current_response->nbody);
63  hashAdd(this->current_response->header,
64  new(HttpHeader, CSTRA("Content-Length"), buffer, nbuf));
65  }
66 
67  nbuf = rfc1123GmtNow(buffer, sizeof(buffer));
68  hashAdd(this->current_response->header,
69  new(HttpHeader, CSTRA("Date"), buffer, nbuf));
70 }
#define CSTRA(val)
Const STRing Argument.
Definition: memory.h:26
void * hashAdd(Hash, void *)
Definition: add.c:48
size_t rfc1123GmtNow(char *, size_t)
Definition: utils/http.c:69
char httpMessageHasKeepAlive(HttpMessage)

+ Here is the call graph for this function:

+ Here is the caller graph for this function: