taskrambler  v0.1.8
Web server and task management solution.
message.h File Reference
#include "class.h"
#include "hash.h"
#include "stream.h"
#include "asset.h"
+ Include dependency graph for message.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

 CLASS (HttpMessage)
 
char httpMessageHasKeepAlive (HttpMessage)
 
size_t httpMessageHeaderSizeGet (HttpMessage)
 
char * httpMessageHeaderToString (HttpMessage, char *)
 
int httpMessageGetVersion (HttpMessage, int *, int *)
 
int httpMessageHasValidVersion (HttpMessage)
 

Detailed Description

Generic HTTP message. Parent for request and response.

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 message.h.

Function Documentation

CLASS ( HttpMessage  )

Definition at line 32 of file message.h.

32  {
33  char * version;
34 
35  Hash header;
36 
37  Asset asset;
38  char * body;
39 
40  int nbody;
41  int dbody;
42 };
int httpMessageGetVersion ( HttpMessage  ,
int *  ,
int *   
)

Definition at line 29 of file get_version.c.

Referenced by httpMessageHasValidVersion().

30 {
31  char * major_ptr = this->version + 5;
32  char * minor_ptr = strchr(major_ptr, '.') + 1;
33  char version[] = "\0\0\0";
34 
35  if (NULL == minor_ptr ||
36  ((minor_ptr - major_ptr - 1) > 2) ||
37  strlen(minor_ptr) > 2)
38  return -1;
39 
40  memcpy(version, major_ptr, minor_ptr - major_ptr - 1);
41  *major = atoi(version);
42 
43  memset(version, 0, 3);
44  strcpy(version, minor_ptr);
45  *minor = atoi(version);
46 
47  return ((*major)<<7)|(*minor);
48 }

+ Here is the caller graph for this function:

char httpMessageHasKeepAlive ( HttpMessage  )

Definition at line 37 of file has_keep_alive.c.

References CSTRA, hashGet(), and size.

Referenced by httpWorkerAddCommonHeader(), and httpWriterWrite().

38 {
39  HttpHeader header;
40  size_t size;
41  char * value;
42 
43  header = hashGet(message->header, CSTRA("connection"));
44 
45  if (NULL == header) {
46  return 0;
47  }
48 
49  size = (header->nvalue)[0];
50  value = (header->value)[0];
51 
52  return (0 == strncasecmp("keep-alive", value, size))? 1 : 0;
53 }
#define CSTRA(val)
Const STRing Argument.
Definition: memory.h:26
static size_t size
void * hashGet(Hash, const char *, size_t)
Definition: hash/get.c:51

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int httpMessageHasValidVersion ( HttpMessage  )

Definition at line 29 of file has_valid_version.c.

References httpMessageGetVersion(), and isHttpVersion().

30 {
31  int major;
32  int minor;
33 
34  if (! isHttpVersion(this->version, strlen(this->version)))
35  return 0;
36 
37  if (0 > httpMessageGetVersion(this, &major, &minor))
38  return 0;
39 
40  if (1 != major)
41  return 0;
42 
43  if (0 > minor || 1 < minor)
44  return 0;
45 
46  return 1;
47 }
int httpMessageGetVersion(HttpMessage, int *, int *)
Definition: get_version.c:29
char isHttpVersion(const char *, size_t)
Definition: utils/http.c:112

+ Here is the call graph for this function:

size_t httpMessageHeaderSizeGet ( HttpMessage  )

Definition at line 44 of file header_size_get.c.

References addHeaderSize(), hashEach(), httpIntroSizeGet(), and size.

Referenced by httpWriterWrite().

45 {
46  size = httpIntroSizeGet(message);
47 
48  hashEach(message->header, addHeaderSize);
49  size += 2;
50 
51  return size;
52 }
static size_t size
static void addHeaderSize(const void *node)
void hashEach(Hash, void(*)(const void *))
Definition: each.c:38
size_t httpIntroSizeGet(void *)
Definition: i_http_intro.c:32

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

char* httpMessageHeaderToString ( HttpMessage  ,
char *   
)

Definition at line 43 of file header_to_string.c.

References addHeaderString(), hashEach(), httpIntroToString(), and string.

Referenced by httpWriterWrite().

44 {
45  HttpMessage message = (HttpMessage)response;
46 
47  string = httpIntroToString(response, _string);
48 
49  hashEach(message->header, addHeaderString);
50 
51  *string++ = '\r';
52  *string++ = '\n';
53 
54  return string;
55 }
char * httpIntroToString(void *, char *)
Definition: i_http_intro.c:42
static void addHeaderString(const void *node)
static char * string
void hashEach(Hash, void(*)(const void *))
Definition: each.c:38

+ Here is the call graph for this function:

+ Here is the caller graph for this function: