src/ebb.h in ebb-0.0.2 vs src/ebb.h in ebb-0.0.3
- old
+ new
@@ -1,8 +1,8 @@
-/* Ebb Web Server
- * Copyright (c) 2007 Ry Dahl <ry.d4hl@gmail.com>
- * This software is released under the "MIT License". See README file for details.
+/* The Ebb Web Server
+ * Copyright (c) 2008 Ry Dahl. This software is released under the MIT
+ * License. See README file for details.
*/
#ifndef ebb_h
#define ebb_h
#include <sys/socket.h>
@@ -16,11 +16,11 @@
typedef struct ebb_server ebb_server;
typedef struct ebb_client ebb_client;
-#define EBB_BUFFERSIZE (40*1024)
+#define EBB_BUFFERSIZE (1024 * (80 + 32) * 2)
#define EBB_MAX_CLIENTS 950
#define EBB_TIMEOUT 30.0
#define EBB_MAX_ENV 100
#define EBB_TCP_COMMON \
unsigned open : 1; \
@@ -28,24 +28,34 @@
struct sockaddr_in sockaddr;
/*** Ebb Client ***/
void ebb_client_close(ebb_client*);
int ebb_client_read(ebb_client *client, char *buffer, int length);
+void ebb_client_write_status(ebb_client*, int status, const char *human_status);
+void ebb_client_write_header(ebb_client*, const char *field, const char *value);
void ebb_client_write(ebb_client*, const char *data, int length);
void ebb_client_finished( ebb_client *client);
-enum { EBB_REQUEST_METHOD
- , EBB_REQUEST_URI
- , EBB_FRAGMENT
- , EBB_REQUEST_PATH
- , EBB_QUERY_STRING
- , EBB_HTTP_VERSION
- , EBB_SERVER_NAME
- , EBB_SERVER_PORT
- , EBB_CONTENT_LENGTH
- };
+struct ebb_env_item {
+ enum { EBB_FIELD_VALUE_PAIR
+ , EBB_REQUEST_METHOD
+ , EBB_REQUEST_URI
+ , EBB_FRAGMENT
+ , EBB_REQUEST_PATH
+ , EBB_QUERY_STRING
+ , EBB_HTTP_VERSION
+ , EBB_SERVER_NAME
+ , EBB_SERVER_PORT
+ , EBB_CONTENT_LENGTH
+ } type;
+ const char *field;
+ int field_length;
+ const char *value;
+ int value_length;
+};
+
struct ebb_client {
EBB_TCP_COMMON
ebb_server *server;
http_parser parser;
@@ -63,15 +73,16 @@
GString *response_buffer;
size_t written;
ev_timer timeout_watcher;
+ int status_sent;
+ int headers_sent;
+ int body_sent;
+
/* the ENV structure */
int env_size;
- const char *env_fields[EBB_MAX_ENV];
- int env_field_lengths[EBB_MAX_ENV];
- const char *env_values[EBB_MAX_ENV];
- int env_value_lengths[EBB_MAX_ENV];
+ struct ebb_env_item env[EBB_MAX_ENV];
};
/*** Ebb Server ***/
typedef void (*ebb_request_cb)(ebb_client*, void*);