105 lines
2.0 KiB
C
105 lines
2.0 KiB
C
#ifndef AISL_STREAM_H_A9EC6601_34B2_4F3E_B631_EEDA8B6EF0D3
|
|
#define AISL_STREAM_H_A9EC6601_34B2_4F3E_B631_EEDA8B6EF0D3
|
|
|
|
#include <aisl/types.h>
|
|
#include <aisl/stream.h>
|
|
#include "buffer.h"
|
|
|
|
#define AISL_STREAM(x) ((aisl_stream_t) x)
|
|
|
|
typedef enum
|
|
{
|
|
AISL_STREAM_STATE_IDLE
|
|
|
|
, AISL_STREAM_STATE_WAIT_HEADER
|
|
, AISL_STREAM_STATE_WAIT_BODY
|
|
|
|
, AISL_STREAM_STATE_READY
|
|
|
|
, AISL_STREAM_STATE_SEND_HEADER
|
|
, AISL_STREAM_STATE_SEND_BODY
|
|
|
|
, AISL_STREAM_STATE_DONE
|
|
|
|
} aisl_stream_state_t;
|
|
|
|
|
|
struct aisl_stream
|
|
{
|
|
struct buffer buffer;
|
|
aisl_client_t client;
|
|
|
|
void * u_ptr;
|
|
|
|
uint64_t content_length;
|
|
int32_t head_offset;
|
|
int32_t body_offset;
|
|
int id;
|
|
int flags;
|
|
|
|
aisl_http_response_t http_response;
|
|
aisl_stream_state_t state;
|
|
};
|
|
|
|
|
|
aisl_stream_t
|
|
aisl_stream_new(aisl_client_t client, int id );
|
|
|
|
|
|
void
|
|
aisl_stream_free(aisl_stream_t stream);
|
|
|
|
|
|
void
|
|
aisl_stream_set_chunked_output(aisl_stream_t stream, bool value);
|
|
|
|
|
|
bool
|
|
aisl_stream_get_chunked_output(aisl_stream_t stream);
|
|
|
|
|
|
int32_t
|
|
aisl_stream_get_buffer_space(aisl_stream_t stream);
|
|
|
|
|
|
int32_t
|
|
aisl_stream_get_buffer_size(aisl_stream_t stream);
|
|
|
|
|
|
char *
|
|
aisl_stream_get_data(aisl_stream_t stream, int32_t * p_length);
|
|
|
|
|
|
void
|
|
aisl_stream_shift(aisl_stream_t stream, int32_t offset);
|
|
|
|
|
|
bool
|
|
aisl_stream_is_done(aisl_stream_t stream);
|
|
|
|
|
|
aisl_stream_state_t
|
|
aisl_stream_get_state(aisl_stream_t stream);
|
|
|
|
|
|
void
|
|
aisl_stream_set_request( aisl_stream_t stream,
|
|
aisl_http_method_t http_method,
|
|
const char * path,
|
|
const char * query );
|
|
|
|
void
|
|
aisl_stream_set_header( aisl_stream_t stream,
|
|
const char * key,
|
|
const char * value );
|
|
|
|
|
|
int
|
|
aisl_stream_set_end_of_headers( aisl_stream_t stream );
|
|
|
|
|
|
int
|
|
aisl_stream_set_body( aisl_stream_t stream, const char * data, int32_t size );
|
|
|
|
#endif /* !AISL_STREAM_H */
|