#ifndef AISL_STREAM_H_A9EC6601_34B2_4F3E_B631_EEDA8B6EF0D3 #define AISL_STREAM_H_A9EC6601_34B2_4F3E_B631_EEDA8B6EF0D3 #include #include #include "list.h" #include "buffer.h" /* -------------------------------------------------------------------------- */ #define STREAM_FLAG_OUTPUT_READY (1<<0) #define STREAM_FLAG_OUTPUT_CHUNKED (1<<1) /* -------------------------------------------------------------------------- */ struct pair { char *key; char *value; }; typedef struct pair * pair_t; /* -------------------------------------------------------------------------- */ typedef enum { STREAM_REQUEST_METHOD, STREAM_REQUEST_PATH, STREAM_REQUEST_PROTOCOL, STREAM_REQUEST_HEADER_KEY, /* HTTP1 header key */ STREAM_REQUEST_HEADER_VALUE, /* HTTP1 header value */ STREAM_REQUEST_CONTENT, /* HTTP1 data value */ /* states below show stream state * and do not show what data was sent to client * */ STREAM_REQUEST_READY, STREAM_RESPONSE_HEADER, STREAM_RESPONSE_CONTENT, STREAM_RESPONSE_READY } aisl_stream_state_t; /* real wrapper for aisl_stream_t */ typedef struct aisl_stream * aisl_stream_t; #define STREAM(x) ((stream_t) x) #define ASTREAM(x) ((aisl_stream_t) x) /* -------------------------------------------------------------------------- */ aisl_stream_t aisl_stream_new(struct sockaddr_in *client, int id, stream_state_t state); /* -------------------------------------------------------------------------- */ void aisl_stream_free(aisl_stream_t self); /* -------------------------------------------------------------------------- */ aisl_stream_t aisl_stream_reset(aisl_stream_t self); /* -------------------------------------------------------------------------- */ #endif /* !AISL_STREAM_H */