|
Server 0.0.1
HTTP/REST server implementation
|
#include "class.h"#include "hash.h"#include "stream.h"

Go to the source code of this file.
Data Structures | |
| struct | HttpMessage |
Typedefs | |
| typedef enum e_HttpMessageType | HttpMessageType |
Enumerations | |
| enum | e_HttpMessageType { HTTP_MESSAGE_BUFFERED = 0, HTTP_MESSAGE_PIPED } |
Functions | |
| char | httpMessageHasKeepAlive (HttpMessage) |
| size_t | httpMessageHeaderSizeGet (HttpMessage) |
| char * | httpMessageHeaderToString (HttpMessage, char *) |
| int | httpMessageGetVersion (HttpMessage, int *, int *) |
| int | httpMessageHasValidVersion (HttpMessage) |
Generic HTTP message. Parent for request and response.
Copyright © 2012 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.
| typedef enum e_HttpMessageType HttpMessageType |
| enum e_HttpMessageType |
| int httpMessageGetVersion | ( | HttpMessage | , |
| int * | , | ||
| int * | |||
| ) |
Definition at line 29 of file get_version.c.
{
char * major_ptr = this->version + 5;
char * minor_ptr = strchr(major_ptr, '.') + 1;
char version[] = "\0\0\0";
if (NULL == minor_ptr ||
((minor_ptr - major_ptr - 1) > 2) ||
strlen(minor_ptr) > 2)
return -1;
memcpy(version, major_ptr, minor_ptr - major_ptr - 1);
*major = atoi(version);
memset(version, 0, 3);
strcpy(version, minor_ptr);
*minor = atoi(version);
return ((*major)<<7)|(*minor);
}

| char httpMessageHasKeepAlive | ( | HttpMessage | ) |
Definition at line 37 of file has_keep_alive.c.
{
HttpHeader header;
size_t size;
char * value;
header = hashGet(message->header, CSTRA("connection"));
if (NULL == header) {
return 0;
}
size = (header->nvalue)[0];
value = (header->value)[0];
return (0 == strncasecmp("keep-alive", value, size))? 1 : 0;
}


| int httpMessageHasValidVersion | ( | HttpMessage | ) |
Definition at line 29 of file has_valid_version.c.
{
int major;
int minor;
if (! isHttpVersion(this->version, strlen(this->version)))
return 0;
if (0 > httpMessageGetVersion(this, &major, &minor))
return 0;
if (1 != major)
return 0;
if (0 > minor || 1 < minor)
return 0;
return 1;
}

| size_t httpMessageHeaderSizeGet | ( | HttpMessage | ) |
Definition at line 44 of file header_size_get.c.
{
size = httpIntroSizeGet(message);
hashEach(message->header, addHeaderSize);
size += 2;
return size;
}


| char* httpMessageHeaderToString | ( | HttpMessage | , |
| char * | |||
| ) |
Definition at line 43 of file header_to_string.c.
{
HttpMessage message = (HttpMessage)response;
string = httpIntroToString(response, _string);
hashEach(message->header, addHeaderString);
*string++ = '\r';
*string++ = '\n';
return string;
}

