2 * NyLPC_cHttpdConnection.h
\r
4 * Created on: 2013/02/07
\r
8 #ifndef NYLPC_CHTTPDCONNECTION_H_
\r
9 #define NYLPC_CHTTPDCONNECTION_H_
\r
10 #include "NyLPC_stdlib.h"
\r
11 #include "NyLPC_uipService.h"
\r
12 #include "NyLPC_cHttpRequestPrefixParser.h"
\r
16 #define NyLPC_NyLPC_TcHttpdConnection_SIZE_OF_RX_BUF 512
\r
19 typedef NyLPC_TUInt8 NyLPC_TcHttpdConnection_Status;
\r
21 /** リクエストプレフィクスを読み出した状態*/
\r
22 #define NyLPC_cHttpdConnection_ReqStatus_LISTEN 0
\r
24 #define NyLPC_cHttpdConnection_ReqStatus_ACCEPT 1
\r
26 #define NyLPC_cHttpdConnection_ReqStatus_PREFETCH 2
\r
28 #define NyLPC_cHttpdConnection_ReqStatus_REQPARSE 3
\r
30 #define NyLPC_cHttpdConnection_ReqStatus_END 4
\r
34 #define NyLPC_cHttpdConnection_ResStatus_HEAD 1
\r
36 #define NyLPC_cHttpdConnection_ResStatus_BODY 2
\r
38 #define NyLPC_cHttpdConnection_ResStatus_CLOSED 3
\r
40 #define NyLPC_cHttpdConnection_ResStatus_ERROR 4
\r
44 * Httpdのハンドラが引き渡す、HTTPDコネクションクラス。
\r
47 typedef struct NyLPC_TcHttpdConnection NyLPC_TcHttpdConnection_t;
\r
48 struct NyLPC_TcHttpdConnection
\r
50 NyLPC_TUInt8 _req_status;//リクエストステータス
\r
51 NyLPC_TUInt8 _res_status;//レスポンスステータス
\r
52 NyLPC_TUInt8 _connection_message_mode;//COnnection:closeをヘッダに書き込むかのフラグ
\r
53 NyLPC_TcTcpSocket_t _socket;
\r
54 NyLPC_TUInt8 _rxbuf[NyLPC_NyLPC_TcHttpdConnection_SIZE_OF_RX_BUF];
\r
55 NyLPC_TcHttpStream_t _in_stream;
\r
56 NyLPC_TcHttpRequestPrefixParser_t _pparser;
\r
58 NyLPC_TcHttpBodyWriter_t _body_writer;
\r
59 NyLPC_TcHttpHeaderWriter_t _head_writer;
\r
63 void NyLPC_cHttpdConnection_initialize(NyLPC_TcHttpdConnection_t* i_inst);
\r
64 void NyLPC_cHttpdConnection_finalize(NyLPC_TcHttpdConnection_t* i_inst);
\r
71 NyLPC_TBool NyLPC_cHttpdConnection_sendResponseHeader(NyLPC_TcHttpdConnection_t* i_inst,NyLPC_TUInt16 i_response_code,const NyLPC_TChar* i_content_type,const NyLPC_TChar* i_additional_header);
\r
76 * 関数を実行後、_res_statusはBODYかERRORに遷移します。
\r
78 NyLPC_TBool NyLPC_cHttpdConnection_sendResponseBody(NyLPC_TcHttpdConnection_t* i_inst,const void* i_data,NyLPC_TUInt16 i_size);
\r
81 * レスポンスBodyを書式出力して送信します。
\r
82 * 関数を実行後、_res_statusはBODYかERRORに遷移します。
\r
84 NyLPC_TBool NyLPC_cHttpdConnection_sendResponseBodyF(NyLPC_TcHttpdConnection_t* i_inst,const char* i_fmt,...);
\r
89 * コネクションのStreamを返します。
\r
91 #define NyLPC_cHttpdConnection_refStream(i_inst) (&(i_inst->_in_stream))
\r
93 #define NyLPC_cHttpdConnection_getStatus(i_inst) (&(i_inst->_pparser.method))
\r
96 #endif /* NYLPC_CHTTPDCONNECTION_H_ */
\r