OSDN Git Service

update libMiMic
[mimic/MiMicSDK.git] / lib / src / net / httpd / NyLPC_cHttpdConnection.c
index f332d2e..7b9a81c 100644 (file)
@@ -1,34 +1,39 @@
 #include "NyLPC_cHttpdConnection_protected.h"\r
 #include "NyLPC_http.h"\r
+#include "NyLPC_netif.h"\r
 #include "NyLPC_cHttpdUtils.h"\r
 #include "./NyLPC_cHttpd_protected.h"\r
 \r
 \r
 \r
-void NyLPC_cHttpdConnection_initialize(NyLPC_TcHttpdConnection_t* i_inst,NyLPC_TcHttpd_t* i_parent_httpd)\r
+NyLPC_TBool NyLPC_cHttpdConnection_initialize(NyLPC_TcHttpdConnection_t* i_inst,NyLPC_TcHttpd_t* i_parent_httpd)\r
 {\r
-       NyLPC_cTcpSocket_initialize(&(i_inst->_socket),i_inst->_rxbuf,NyLPC_cHttpdConnection_SIZE_OF_RX_BUF);\r
-       NyLPC_cHttpRequestPrefixParser_initialize(&(i_inst->_pparser));\r
-       i_inst->_parent_httpd=i_parent_httpd;\r
-       i_inst->_res_status=NyLPC_cHttpdConnection_ResStatus_CLOSED;\r
-       i_inst->_req_status=NyLPC_cHttpdConnection_ReqStatus_LISTEN;\r
+    i_inst->_socket=NyLPC_cNet_createTcpSocketEx(NyLPC_TSocketType_TCP_HTTP);\r
+    if(i_inst->_socket==NULL){\r
+        return NyLPC_TBool_FALSE;\r
+    }\r
+    NyLPC_cHttpRequestPrefixParser_initialize(&(i_inst->_pparser));\r
+    i_inst->_parent_httpd=i_parent_httpd;\r
+    i_inst->_res_status=NyLPC_cHttpdConnection_ResStatus_CLOSED;\r
+    i_inst->_req_status=NyLPC_cHttpdConnection_ReqStatus_LISTEN;\r
+    return NyLPC_TBool_TRUE;\r
 }\r
 \r
 void NyLPC_cHttpdConnection_finalize(NyLPC_TcHttpdConnection_t* i_inst)\r
 {\r
-       NyLPC_cHttpdConnection_closeResponse(i_inst);\r
-       NyLPC_cHttpdConnection_closeSocket(i_inst);\r
-       NyLPC_cHttpRequestPrefixParser_finalize(i_inst);\r
-       NyLPC_cTcpSocket_finalize(&(i_inst->_socket));\r
+    NyLPC_cHttpdConnection_closeResponse(i_inst);\r
+    NyLPC_cHttpdConnection_closeSocket(i_inst);\r
+    NyLPC_cHttpRequestPrefixParser_finalize(i_inst);\r
+    NyLPC_iTcpSocket_finalize(i_inst->_socket);\r
 }\r
 \r
 const NyLPC_TChar* NyLPC_cHttpdConnection_getUrlPrefix(const NyLPC_TcHttpdConnection_t* i_inst)\r
 {\r
-       return NyLPC_cHttpRequestPrefixParser_getUrlPrefix(&i_inst->_pparser);\r
+    return NyLPC_cHttpRequestPrefixParser_getUrlPrefix(&i_inst->_pparser);\r
 }\r
 void NyLPC_cHttpdConnection_setReqStatusParsed(NyLPC_TcHttpdConnection_t* i_inst)\r
 {\r
-       i_inst->_req_status=NyLPC_cHttpdConnection_ReqStatus_END;\r
+    i_inst->_req_status=NyLPC_cHttpdConnection_ReqStatus_END;\r
 }\r
 \r
 #define NyLPC_cHttpHeaderWriter_CONTENT_LENGTH_UNLIMITED 0xFFFFFFFF\r
@@ -36,20 +41,20 @@ void NyLPC_cHttpdConnection_setReqStatusParsed(NyLPC_TcHttpdConnection_t* i_inst
 \r
 NyLPC_TBool NyLPC_cHttpdConnection_send100Continue(NyLPC_TcHttpdConnection_t* i_inst)\r
 {\r
-       //状態の確認\r
-       if(i_inst->_res_status!=NyLPC_cHttpdConnection_ResStatus_HEAD)\r
-       {\r
-               NyLPC_OnErrorGoto(Error_Status);\r
-       }\r
-       //ステータスラインの記述\r
-       if(!NyLPC_iHttpPtrStream_write(&(i_inst->_in_stream.super),"HTTP/1.1 100 Continue\r\n\r\n",25)){\r
-               NyLPC_OnErrorGoto(Error);\r
-       }\r
-       return NyLPC_TBool_TRUE;\r
+    //状態の確認\r
+    if(i_inst->_res_status!=NyLPC_cHttpdConnection_ResStatus_HEAD)\r
+    {\r
+        NyLPC_OnErrorGoto(Error_Status);\r
+    }\r
+    //ステータスラインの記述\r
+    if(!NyLPC_iHttpPtrStream_write(&(i_inst->_in_stream.super),"HTTP/1.1 100 Continue\r\n\r\n",25)){\r
+        NyLPC_OnErrorGoto(Error);\r
+    }\r
+    return NyLPC_TBool_TRUE;\r
 Error:\r
 Error_Status:\r
-       i_inst->_res_status=NyLPC_cHttpdConnection_ResStatus_ERROR;\r
-       return NyLPC_TBool_FALSE;\r
+    i_inst->_res_status=NyLPC_cHttpdConnection_ResStatus_ERROR;\r
+    return NyLPC_TBool_FALSE;\r
 }\r
 \r
 /**\r
@@ -57,58 +62,58 @@ Error_Status:
  */\r
 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
 {\r
-       return NyLPC_cHttpdConnection_sendResponseHeader2(i_inst,i_response_code,i_content_type,NyLPC_cHttpHeaderWriter_CONTENT_LENGTH_UNLIMITED,i_additional_header);\r
+    return NyLPC_cHttpdConnection_sendResponseHeader2(i_inst,i_response_code,i_content_type,NyLPC_cHttpHeaderWriter_CONTENT_LENGTH_UNLIMITED,i_additional_header);\r
 }\r
 \r
 NyLPC_TBool NyLPC_cHttpdConnection_sendResponseHeader2(NyLPC_TcHttpdConnection_t* i_inst,NyLPC_TUInt16 i_response_code,const NyLPC_TChar* i_content_type,NyLPC_TUInt32 i_content_length,const NyLPC_TChar* i_additional_header)\r
 {\r
-       NyLPC_TcHttpHeaderWriter_t* h=&(i_inst->_head_writer);\r
-       //状態の確認\r
-       if(i_inst->_res_status!=NyLPC_cHttpdConnection_ResStatus_HEAD)\r
-       {\r
-               NyLPC_OnErrorGoto(Error_Status);\r
-       }\r
-       //ヘッダ送信\r
-       if(!NyLPC_cHttpHeaderWriter_initialize(h,&(i_inst->_in_stream.super),NULL)){\r
-               NyLPC_OnErrorGoto(ERROR_SEND);\r
-       }\r
-       //Headerの転送モードセット\r
-       if(i_content_length==NyLPC_cHttpHeaderWriter_CONTENT_LENGTH_UNLIMITED){\r
-               NyLPC_cHttpHeaderWriter_setChunked(h);\r
-       }else{\r
-               NyLPC_cHttpHeaderWriter_setContentLength(h,i_content_length);\r
-       }\r
-       //continueにセットされていたらcloseをFALSEに\r
-       NyLPC_cHttpHeaderWriter_setConnectionClose(h,(i_inst->_connection_message_mode!=NyLPC_TcHttpdConnection_CONNECTION_MODE_CONTINUE));\r
-\r
-       if(!NyLPC_cHttpHeaderWriter_writeResponseHeader(h,i_response_code)){\r
-               NyLPC_OnErrorGoto(ERROR_SEND);\r
-       }\r
-       if(!NyLPC_cHttpHeaderWriter_writeMessage(h,"Content-type",i_content_type)){\r
-               NyLPC_OnErrorGoto(ERROR_SEND);\r
-       }\r
-       if(i_additional_header!=NULL){\r
-               if(!NyLPC_cHttpHeaderWriter_writeRawMessage(h,i_additional_header)){\r
-                       NyLPC_OnErrorGoto(ERROR_SEND);\r
-               }\r
-       }\r
-       NyLPC_cHttpHeaderWriter_close(h);\r
-       NyLPC_cHttpHeaderWriter_finalize(h);\r
-       i_inst->_res_status=NyLPC_cHttpdConnection_ResStatus_BODY;\r
-       //BodyWriter生成\r
-       NyLPC_cHttpBodyWriter_initialize(&(i_inst->_body_writer),&(i_inst->_in_stream));\r
-       //bodyのchunkedもセット\r
-       if(i_content_length==NyLPC_cHttpHeaderWriter_CONTENT_LENGTH_UNLIMITED){\r
-               NyLPC_cHttpBodyWriter_setChunked(&(i_inst->_body_writer));\r
-       }else{\r
-               NyLPC_cHttpBodyWriter_setContentLength(&(i_inst->_body_writer),i_content_length);\r
-       }\r
-       return NyLPC_TBool_TRUE;\r
+    NyLPC_TcHttpHeaderWriter_t* h=&(i_inst->_head_writer);\r
+    //状態の確認\r
+    if(i_inst->_res_status!=NyLPC_cHttpdConnection_ResStatus_HEAD)\r
+    {\r
+        NyLPC_OnErrorGoto(Error_Status);\r
+    }\r
+    //ヘッダ送信\r
+    if(!NyLPC_cHttpHeaderWriter_initialize(h,&(i_inst->_in_stream.super),NULL)){\r
+        NyLPC_OnErrorGoto(ERROR_SEND);\r
+    }\r
+    //Headerの転送モードセット\r
+    if(i_content_length==NyLPC_cHttpHeaderWriter_CONTENT_LENGTH_UNLIMITED){\r
+        NyLPC_cHttpHeaderWriter_setChunked(h);\r
+    }else{\r
+        NyLPC_cHttpHeaderWriter_setContentLength(h,i_content_length);\r
+    }\r
+    //continueにセットされていたらcloseをFALSEに\r
+    NyLPC_cHttpHeaderWriter_setConnectionClose(h,(i_inst->_connection_message_mode!=NyLPC_TcHttpdConnection_CONNECTION_MODE_CONTINUE));\r
+\r
+    if(!NyLPC_cHttpHeaderWriter_writeResponseHeader(h,i_response_code)){\r
+        NyLPC_OnErrorGoto(ERROR_SEND);\r
+    }\r
+    if(!NyLPC_cHttpHeaderWriter_writeMessage(h,"Content-type",i_content_type)){\r
+        NyLPC_OnErrorGoto(ERROR_SEND);\r
+    }\r
+    if(i_additional_header!=NULL){\r
+        if(!NyLPC_cHttpHeaderWriter_writeRawMessage(h,i_additional_header)){\r
+            NyLPC_OnErrorGoto(ERROR_SEND);\r
+        }\r
+    }\r
+    NyLPC_cHttpHeaderWriter_close(h);\r
+    NyLPC_cHttpHeaderWriter_finalize(h);\r
+    i_inst->_res_status=NyLPC_cHttpdConnection_ResStatus_BODY;\r
+    //BodyWriter生成\r
+    NyLPC_cHttpBodyWriter_initialize(&(i_inst->_body_writer),&(i_inst->_in_stream));\r
+    //bodyのchunkedもセット\r
+    if(i_content_length==NyLPC_cHttpHeaderWriter_CONTENT_LENGTH_UNLIMITED){\r
+        NyLPC_cHttpBodyWriter_setChunked(&(i_inst->_body_writer));\r
+    }else{\r
+        NyLPC_cHttpBodyWriter_setContentLength(&(i_inst->_body_writer),i_content_length);\r
+    }\r
+    return NyLPC_TBool_TRUE;\r
 ERROR_SEND:\r
-       NyLPC_cHttpHeaderWriter_finalize(&(i_inst->_head_writer));\r
+    NyLPC_cHttpHeaderWriter_finalize(&(i_inst->_head_writer));\r
 Error_Status:\r
-       i_inst->_res_status=NyLPC_cHttpdConnection_ResStatus_ERROR;\r
-       return NyLPC_TBool_FALSE;\r
+    i_inst->_res_status=NyLPC_cHttpdConnection_ResStatus_ERROR;\r
+    return NyLPC_TBool_FALSE;\r
 }\r
 \r
 \r
@@ -118,20 +123,20 @@ Error_Status:
  */\r
 NyLPC_TBool NyLPC_cHttpdConnection_sendResponseBody(NyLPC_TcHttpdConnection_t* i_inst,const void* i_data,NyLPC_TUInt32 i_size)\r
 {\r
-       if(i_inst->_res_status!=NyLPC_cHttpdConnection_ResStatus_BODY)\r
-       {\r
-               NyLPC_OnErrorGoto(Error);\r
-       }\r
-       //Bodyの書込み\r
-       if(!NyLPC_cHttpBodyWriter_write(&(i_inst->_body_writer),i_data,i_size)){\r
-               NyLPC_OnErrorGoto(Error_Send);\r
-       }\r
-       return NyLPC_TBool_TRUE;\r
+    if(i_inst->_res_status!=NyLPC_cHttpdConnection_ResStatus_BODY)\r
+    {\r
+        NyLPC_OnErrorGoto(Error);\r
+    }\r
+    //Bodyの書込み\r
+    if(!NyLPC_cHttpBodyWriter_write(&(i_inst->_body_writer),i_data,i_size)){\r
+        NyLPC_OnErrorGoto(Error_Send);\r
+    }\r
+    return NyLPC_TBool_TRUE;\r
 Error_Send:\r
-       NyLPC_cHttpBodyWriter_finalize(&(i_inst->_in_stream));\r
+    NyLPC_cHttpBodyWriter_finalize(&(i_inst->_in_stream));\r
 Error:\r
-       i_inst->_res_status=NyLPC_cHttpdConnection_ResStatus_ERROR;\r
-       return NyLPC_TBool_FALSE;\r
+    i_inst->_res_status=NyLPC_cHttpdConnection_ResStatus_ERROR;\r
+    return NyLPC_TBool_FALSE;\r
 }\r
 /**\r
  * レスポンスBodyを書式出力して送信します。\r
@@ -139,24 +144,24 @@ Error:
  */\r
 NyLPC_TBool NyLPC_cHttpdConnection_sendResponseBodyF(NyLPC_TcHttpdConnection_t* i_inst,const char* i_fmt,...)\r
 {\r
-       va_list a;\r
-       if(i_inst->_res_status!=NyLPC_cHttpdConnection_ResStatus_BODY)\r
-       {\r
-               NyLPC_OnErrorGoto(Error);\r
-       }\r
-       //Bodyの書込み\r
-       va_start(a,i_fmt);\r
-       if(!NyLPC_cHttpBodyWriter_formatV(&(i_inst->_body_writer),i_fmt,a)){\r
-               NyLPC_OnErrorGoto(Error_Send);\r
-       }\r
-       va_end(a);\r
-       return NyLPC_TBool_TRUE;\r
+    va_list a;\r
+    if(i_inst->_res_status!=NyLPC_cHttpdConnection_ResStatus_BODY)\r
+    {\r
+        NyLPC_OnErrorGoto(Error);\r
+    }\r
+    //Bodyの書込み\r
+    va_start(a,i_fmt);\r
+    if(!NyLPC_cHttpBodyWriter_formatV(&(i_inst->_body_writer),i_fmt,a)){\r
+        NyLPC_OnErrorGoto(Error_Send);\r
+    }\r
+    va_end(a);\r
+    return NyLPC_TBool_TRUE;\r
 Error_Send:\r
-       va_end(a);\r
-       NyLPC_cHttpBodyWriter_finalize(&(i_inst->_in_stream));\r
+    va_end(a);\r
+    NyLPC_cHttpBodyWriter_finalize(&(i_inst->_in_stream));\r
 Error:\r
-       i_inst->_res_status=NyLPC_cHttpdConnection_ResStatus_ERROR;\r
-       return NyLPC_TBool_FALSE;\r
+    i_inst->_res_status=NyLPC_cHttpdConnection_ResStatus_ERROR;\r
+    return NyLPC_TBool_FALSE;\r
 }\r
 \r
 /**\r
@@ -165,47 +170,47 @@ Error:
  */\r
 static void sendErrorResponse(NyLPC_TcHttpdConnection_t* i_inst,NyLPC_TInt16 i_status)\r
 {\r
-       NyLPC_TcHttpHeaderWriter_t* h=&(i_inst->_head_writer);\r
-       if(NyLPC_cHttpHeaderWriter_initialize(h,&i_inst->_in_stream.super,NULL)){\r
-               //ヘッダを送信\r
-               NyLPC_cHttpHeaderWriter_setConnectionClose(h,NyLPC_TBool_TRUE);\r
-               NyLPC_cHttpHeaderWriter_writeResponseHeader(h,i_status);\r
-               NyLPC_cHttpHeaderWriter_close(h);\r
-               NyLPC_cHttpHeaderWriter_finalize(h);\r
-       }\r
+    NyLPC_TcHttpHeaderWriter_t* h=&(i_inst->_head_writer);\r
+    if(NyLPC_cHttpHeaderWriter_initialize(h,&i_inst->_in_stream.super,NULL)){\r
+        //ヘッダを送信\r
+        NyLPC_cHttpHeaderWriter_setConnectionClose(h,NyLPC_TBool_TRUE);\r
+        NyLPC_cHttpHeaderWriter_writeResponseHeader(h,i_status);\r
+        NyLPC_cHttpHeaderWriter_close(h);\r
+        NyLPC_cHttpHeaderWriter_finalize(h);\r
+    }\r
 }\r
 /**\r
  * 関数を実行後、_res_statusはCLOSEDかHEADかERRORに遷移する。\r
  */\r
 NyLPC_TBool NyLPC_cHttpdConnection_closeResponse(NyLPC_TcHttpdConnection_t* i_inst)\r
 {\r
-       NyLPC_TcHttpBodyWriter_t* b;\r
-       switch(i_inst->_res_status){\r
-       case NyLPC_cHttpdConnection_ResStatus_CLOSED:\r
-       case NyLPC_cHttpdConnection_ResStatus_ERROR:\r
-               //何もせずにコネクションをクローズする。\r
-               return NyLPC_TBool_FALSE;\r
-       case NyLPC_cHttpdConnection_ResStatus_HEAD:\r
-               //エラー500を送信してクローズする。\r
-               sendErrorResponse(i_inst,500);\r
-               i_inst->_res_status=NyLPC_cHttpdConnection_ResStatus_CLOSED;\r
-               return NyLPC_TBool_FALSE;\r
-       case NyLPC_cHttpdConnection_ResStatus_BODY:\r
-               //正常終了。BODYをクローズし、終了する。\r
-               b=&(i_inst->_body_writer);\r
-               NyLPC_cHttpBodyWriter_close(b);\r
-               NyLPC_cHttpBodyWriter_finalize(&b);\r
-               i_inst->_res_status=NyLPC_cHttpdConnection_ResStatus_HEAD;\r
-               if(i_inst->_connection_message_mode!=NyLPC_TcHttpdConnection_CONNECTION_MODE_CONTINUE)\r
-               {\r
-                       i_inst->_res_status=NyLPC_cHttpdConnection_ResStatus_CLOSED;\r
-                       return NyLPC_TBool_FALSE;\r
-               }\r
-               return NyLPC_TBool_TRUE;\r
-       default:\r
-               NyLPC_Abort();\r
-       }\r
-       return NyLPC_TBool_TRUE;\r
+    NyLPC_TcHttpBodyWriter_t* b;\r
+    switch(i_inst->_res_status){\r
+    case NyLPC_cHttpdConnection_ResStatus_CLOSED:\r
+    case NyLPC_cHttpdConnection_ResStatus_ERROR:\r
+        //何もせずにコネクションをクローズする。\r
+        return NyLPC_TBool_FALSE;\r
+    case NyLPC_cHttpdConnection_ResStatus_HEAD:\r
+        //エラー500を送信してクローズする。\r
+        sendErrorResponse(i_inst,500);\r
+        i_inst->_res_status=NyLPC_cHttpdConnection_ResStatus_CLOSED;\r
+        return NyLPC_TBool_FALSE;\r
+    case NyLPC_cHttpdConnection_ResStatus_BODY:\r
+        //正常終了。BODYをクローズし、終了する。\r
+        b=&(i_inst->_body_writer);\r
+        NyLPC_cHttpBodyWriter_close(b);\r
+        NyLPC_cHttpBodyWriter_finalize(&b);\r
+        i_inst->_res_status=NyLPC_cHttpdConnection_ResStatus_HEAD;\r
+        if(i_inst->_connection_message_mode!=NyLPC_TcHttpdConnection_CONNECTION_MODE_CONTINUE)\r
+        {\r
+            i_inst->_res_status=NyLPC_cHttpdConnection_ResStatus_CLOSED;\r
+            return NyLPC_TBool_FALSE;\r
+        }\r
+        return NyLPC_TBool_TRUE;\r
+    default:\r
+        NyLPC_Abort();\r
+    }\r
+    return NyLPC_TBool_TRUE;\r
 }\r
 \r
 /**\r
@@ -213,39 +218,39 @@ NyLPC_TBool NyLPC_cHttpdConnection_closeResponse(NyLPC_TcHttpdConnection_t* i_in
  */\r
 NyLPC_TBool NyLPC_cHttpdConnection_pushPrefetchInfo(NyLPC_TcHttpdConnection_t* i_inst,NyLPC_TcHttpBasicHeaderParser_t* i_header_parser,struct NyLPC_THttpBasicHeader* o_out)\r
 {\r
-       const char* method=NyLPC_THttpMethodType_toString(i_inst->_pparser.method);\r
-       if(NyLPC_cHttpBasicHeaderParser_parseChar(i_header_parser,method,strlen(method),o_out)<0){\r
-               NyLPC_OnErrorGoto(Error);\r
-       }\r
-       if(NyLPC_cHttpBasicHeaderParser_parseChar(i_header_parser," ",1,o_out)<0){\r
-               NyLPC_OnErrorGoto(Error);\r
-       }\r
-       if(NyLPC_cHttpBasicHeaderParser_parseChar(i_header_parser,i_inst->_pparser._url,strlen(i_inst->_pparser._url),o_out)<0){\r
-               NyLPC_OnErrorGoto(Error);\r
-       }\r
-       return NyLPC_TBool_TRUE;\r
+    const char* method=NyLPC_THttpMethodType_toString(i_inst->_pparser.method);\r
+    if(NyLPC_cHttpBasicHeaderParser_parseChar(i_header_parser,method,strlen(method),o_out)<0){\r
+        NyLPC_OnErrorGoto(Error);\r
+    }\r
+    if(NyLPC_cHttpBasicHeaderParser_parseChar(i_header_parser," ",1,o_out)<0){\r
+        NyLPC_OnErrorGoto(Error);\r
+    }\r
+    if(NyLPC_cHttpBasicHeaderParser_parseChar(i_header_parser,i_inst->_pparser._url,strlen(i_inst->_pparser._url),o_out)<0){\r
+        NyLPC_OnErrorGoto(Error);\r
+    }\r
+    return NyLPC_TBool_TRUE;\r
 Error:\r
-       return NyLPC_TBool_FALSE;\r
+    return NyLPC_TBool_FALSE;\r
 }\r
 \r
-#define NyLPC_cHttpdConnection_TIMEOUT_ACCEPT  3000\r
-#define NyLPC_cHttpdConnection_TIMEOUT_CLOSE   5000\r
-#define NyLPC_cHttpdConnection_TIMEOUT_LISTEN  5000\r
+#define NyLPC_cHttpdConnection_TIMEOUT_ACCEPT   3000\r
+#define NyLPC_cHttpdConnection_TIMEOUT_CLOSE    5000\r
+#define NyLPC_cHttpdConnection_TIMEOUT_LISTEN   5000\r
 \r
 \r
 /**\r
  * listenerでConnectionのソケットに接続を待ちます。\r
  */\r
-NyLPC_TBool NyLPC_cHttpdConnection_listenSocket(NyLPC_TcHttpdConnection_t* i_inst,NyLPC_TcTcpListener_t* i_listener)\r
+NyLPC_TBool NyLPC_cHttpdConnection_listenSocket(NyLPC_TcHttpdConnection_t* i_inst,NyLPC_TiTcpListener_t* i_listener)\r
 {\r
-       NyLPC_Assert(i_inst->_req_status==NyLPC_cHttpdConnection_ReqStatus_LISTEN);\r
-       //リスニング\r
-       if(!NyLPC_cTcpListener_listen(i_listener,&(i_inst->_socket),NyLPC_cHttpdConnection_TIMEOUT_LISTEN)){\r
-               return NyLPC_TBool_FALSE;\r
-       }\r
-       //成功したらステータス遷移\r
-       i_inst->_req_status=NyLPC_cHttpdConnection_ReqStatus_ACCEPT;\r
-       return NyLPC_TBool_TRUE;\r
+    NyLPC_Assert(i_inst->_req_status==NyLPC_cHttpdConnection_ReqStatus_LISTEN);\r
+    //リスニング\r
+    if(!NyLPC_iTcpListener_listen(i_listener,i_inst->_socket,NyLPC_cHttpdConnection_TIMEOUT_LISTEN)){\r
+        return NyLPC_TBool_FALSE;\r
+    }\r
+    //成功したらステータス遷移\r
+    i_inst->_req_status=NyLPC_cHttpdConnection_ReqStatus_ACCEPT;\r
+    return NyLPC_TBool_TRUE;\r
 }\r
 \r
 /**\r
@@ -253,43 +258,43 @@ NyLPC_TBool NyLPC_cHttpdConnection_listenSocket(NyLPC_TcHttpdConnection_t* i_ins
  */\r
 NyLPC_TBool NyLPC_cHttpdConnection_acceptSocket(NyLPC_TcHttpdConnection_t* i_inst)\r
 {\r
-       NyLPC_Assert(i_inst->_req_status==NyLPC_cHttpdConnection_ReqStatus_ACCEPT);\r
-\r
-       if(!NyLPC_cTcpSocket_accept(&(i_inst->_socket),NyLPC_cHttpdConnection_TIMEOUT_ACCEPT)){\r
-               NyLPC_OnErrorGoto(Error);\r
-       }\r
-       //HttpStreamの生成\r
-       if(!NyLPC_cHttpStream_initialize(&i_inst->_in_stream,&(i_inst->_socket))){\r
-               NyLPC_OnErrorGoto(Error_Connected);\r
-       }\r
-       //初回だけHEADに遷移\r
-       i_inst->_res_status=NyLPC_cHttpdConnection_ResStatus_HEAD;\r
-       i_inst->_req_status=NyLPC_cHttpdConnection_ReqStatus_PREFETCH;\r
-       i_inst->_connection_message_mode=NyLPC_TcHttpdConnection_CONNECTION_MODE_CLOSE;\r
-       return NyLPC_TBool_TRUE;\r
+    NyLPC_Assert(i_inst->_req_status==NyLPC_cHttpdConnection_ReqStatus_ACCEPT);\r
+\r
+    if(!NyLPC_iTcpSocket_accept(i_inst->_socket,NyLPC_cHttpdConnection_TIMEOUT_ACCEPT)){\r
+        NyLPC_OnErrorGoto(Error);\r
+    }\r
+    //HttpStreamの生成\r
+    if(!NyLPC_cHttpStream_initialize(&i_inst->_in_stream,i_inst->_socket)){\r
+        NyLPC_OnErrorGoto(Error_Connected);\r
+    }\r
+    //初回だけHEADに遷移\r
+    i_inst->_res_status=NyLPC_cHttpdConnection_ResStatus_HEAD;\r
+    i_inst->_req_status=NyLPC_cHttpdConnection_ReqStatus_PREFETCH;\r
+    i_inst->_connection_message_mode=NyLPC_TcHttpdConnection_CONNECTION_MODE_CLOSE;\r
+    return NyLPC_TBool_TRUE;\r
 Error_Connected:\r
-       NyLPC_cTcpSocket_close(&(i_inst->_socket),NyLPC_cHttpdConnection_TIMEOUT_CLOSE);\r
-       i_inst->_req_status=NyLPC_cHttpdConnection_ReqStatus_LISTEN;\r
+    NyLPC_iTcpSocket_close(i_inst->_socket,NyLPC_cHttpdConnection_TIMEOUT_CLOSE);\r
+    i_inst->_req_status=NyLPC_cHttpdConnection_ReqStatus_LISTEN;\r
 Error:\r
-       return NyLPC_TBool_FALSE;\r
+    return NyLPC_TBool_FALSE;\r
 }\r
 \r
 NyLPC_TBool NyLPC_cHttpdConnection_prefetch(NyLPC_TcHttpdConnection_t* i_inst)\r
 {\r
-       NyLPC_Assert(i_inst->_req_status==NyLPC_cHttpdConnection_ReqStatus_PREFETCH);\r
-\r
-       //Prefetchを実行\r
-       if(!NyLPC_cHttpRequestPrefixParser_parse(&i_inst->_pparser,&i_inst->_in_stream.super)){\r
-               //400エラー\r
-               sendErrorResponse(i_inst,400);\r
-               NyLPC_OnErrorGoto(Error_Prefetch);\r
-       }\r
-       i_inst->_req_status=NyLPC_cHttpdConnection_ReqStatus_REQPARSE;\r
-       return NyLPC_TBool_TRUE;\r
+    NyLPC_Assert(i_inst->_req_status==NyLPC_cHttpdConnection_ReqStatus_PREFETCH);\r
+\r
+    //Prefetchを実行\r
+    if(!NyLPC_cHttpRequestPrefixParser_parse(&i_inst->_pparser,&i_inst->_in_stream.super)){\r
+        //400エラー\r
+        sendErrorResponse(i_inst,400);\r
+        NyLPC_OnErrorGoto(Error_Prefetch);\r
+    }\r
+    i_inst->_req_status=NyLPC_cHttpdConnection_ReqStatus_REQPARSE;\r
+    return NyLPC_TBool_TRUE;\r
 Error_Prefetch:\r
-       NyLPC_cTcpSocket_close(&(i_inst->_socket),NyLPC_cHttpdConnection_TIMEOUT_CLOSE);\r
-       i_inst->_req_status=NyLPC_cHttpdConnection_ReqStatus_LISTEN;\r
-       return NyLPC_TBool_FALSE;\r
+    NyLPC_iTcpSocket_close(i_inst->_socket,NyLPC_cHttpdConnection_TIMEOUT_CLOSE);\r
+    i_inst->_req_status=NyLPC_cHttpdConnection_ReqStatus_LISTEN;\r
+    return NyLPC_TBool_FALSE;\r
 }\r
 \r
 \r
@@ -300,58 +305,58 @@ Error_Prefetch:
 \r
 NyLPC_TBool NyLPC_cHttpdConnection_prevNextPrefetch(NyLPC_TcHttpdConnection_t* i_inst)\r
 {\r
-       NyLPC_TcHttpNullRequestHeaderParser_t parser;\r
-       switch(i_inst->_req_status)\r
-       {\r
-       case NyLPC_cHttpdConnection_ReqStatus_REQPARSE:\r
-               //リクエストパース待ちなら前段のリクエストを吸収しておく。\r
-               NyLPC_cHttpNullRequestHeaderParser_initialize(&parser);\r
-               //プリフェッチしたデータを流す\r
-               NyLPC_cHttpNullRequestHeaderParser_parseInit(&parser);\r
-               NyLPC_cHttpNullRequestHeaderParser_parseChar(&parser,"GET ",4);//決め打ち\r
-               NyLPC_cHttpNullRequestHeaderParser_parseChar(&parser,i_inst->_pparser._url,strlen(i_inst->_pparser._url));\r
-               //後続をストリームから取り込む\r
-               if(NyLPC_cHttpNullRequestHeaderParser_parseStream(&parser,&(i_inst->_in_stream.super))){\r
-                       if(NyLPC_cHttpNullRequestHeaderParser_parseFinish(&parser)){\r
-                               NyLPC_cHttpNullRequestHeaderParser_finalize(&parser);\r
-                               //OK:403\r
-                               sendErrorResponse(i_inst,403);\r
-                               break;//OK\r
-                       }\r
-               }\r
-\r
-               NyLPC_cHttpNullRequestHeaderParser_finalize(&parser);\r
-               //NG:400 Bad Request\r
-               sendErrorResponse(i_inst,400);\r
-               return NyLPC_TBool_FALSE;//吸収失敗\r
-       case NyLPC_cHttpdConnection_ReqStatus_END:\r
-               //リクエストがパース済みならprefetchに戻す。\r
-               i_inst->_req_status=NyLPC_cHttpdConnection_ReqStatus_PREFETCH;\r
-       default:\r
-               NyLPC_Abort();\r
-       }\r
-       //吸収成功\r
-       return NyLPC_TBool_TRUE;\r
+    NyLPC_TcHttpNullRequestHeaderParser_t parser;\r
+    switch(i_inst->_req_status)\r
+    {\r
+    case NyLPC_cHttpdConnection_ReqStatus_REQPARSE:\r
+        //リクエストパース待ちなら前段のリクエストを吸収しておく。\r
+        NyLPC_cHttpNullRequestHeaderParser_initialize(&parser);\r
+        //プリフェッチしたデータを流す\r
+        NyLPC_cHttpNullRequestHeaderParser_parseInit(&parser);\r
+        NyLPC_cHttpNullRequestHeaderParser_parseChar(&parser,"GET ",4);//決め打ち\r
+        NyLPC_cHttpNullRequestHeaderParser_parseChar(&parser,i_inst->_pparser._url,strlen(i_inst->_pparser._url));\r
+        //後続をストリームから取り込む\r
+        if(NyLPC_cHttpNullRequestHeaderParser_parseStream(&parser,&(i_inst->_in_stream.super))){\r
+            if(NyLPC_cHttpNullRequestHeaderParser_parseFinish(&parser)){\r
+                NyLPC_cHttpNullRequestHeaderParser_finalize(&parser);\r
+                //OK:403\r
+                sendErrorResponse(i_inst,403);\r
+                break;//OK\r
+            }\r
+        }\r
+\r
+        NyLPC_cHttpNullRequestHeaderParser_finalize(&parser);\r
+        //NG:400 Bad Request\r
+        sendErrorResponse(i_inst,400);\r
+        return NyLPC_TBool_FALSE;//吸収失敗\r
+    case NyLPC_cHttpdConnection_ReqStatus_END:\r
+        //リクエストがパース済みならprefetchに戻す。\r
+        i_inst->_req_status=NyLPC_cHttpdConnection_ReqStatus_PREFETCH;\r
+    default:\r
+        NyLPC_Abort();\r
+    }\r
+    //吸収成功\r
+    return NyLPC_TBool_TRUE;\r
 }\r
 \r
 void NyLPC_cHttpdConnection_closeSocket(NyLPC_TcHttpdConnection_t* i_inst)\r
 {\r
-       switch(i_inst->_req_status)\r
-       {\r
-       case NyLPC_cHttpdConnection_ReqStatus_LISTEN:\r
-               //何も出来ない。\r
-               break;\r
-       case NyLPC_cHttpdConnection_ReqStatus_END:\r
-       case NyLPC_cHttpdConnection_ReqStatus_REQPARSE:\r
-       case NyLPC_cHttpdConnection_ReqStatus_PREFETCH:\r
-               NyLPC_cHttpStream_finalize(&i_inst->_in_stream);\r
-       case NyLPC_cHttpdConnection_ReqStatus_ACCEPT:\r
-               NyLPC_cTcpSocket_close(&(i_inst->_socket),NyLPC_cHttpdConnection_TIMEOUT_CLOSE);\r
-       default:\r
-               break;\r
-       }\r
-       i_inst->_req_status=NyLPC_cHttpdConnection_ReqStatus_LISTEN;\r
-       i_inst->_res_status=NyLPC_cHttpdConnection_ResStatus_CLOSED;\r
+    switch(i_inst->_req_status)\r
+    {\r
+    case NyLPC_cHttpdConnection_ReqStatus_LISTEN:\r
+        //何も出来ない。\r
+        break;\r
+    case NyLPC_cHttpdConnection_ReqStatus_END:\r
+    case NyLPC_cHttpdConnection_ReqStatus_REQPARSE:\r
+    case NyLPC_cHttpdConnection_ReqStatus_PREFETCH:\r
+        NyLPC_cHttpStream_finalize(&i_inst->_in_stream);\r
+    case NyLPC_cHttpdConnection_ReqStatus_ACCEPT:\r
+        NyLPC_iTcpSocket_close(i_inst->_socket,NyLPC_cHttpdConnection_TIMEOUT_CLOSE);\r
+    default:\r
+        break;\r
+    }\r
+    i_inst->_req_status=NyLPC_cHttpdConnection_ReqStatus_LISTEN;\r
+    i_inst->_res_status=NyLPC_cHttpdConnection_ResStatus_CLOSED;\r
 }\r
 \r
 /**\r
@@ -359,12 +364,12 @@ void NyLPC_cHttpdConnection_closeSocket(NyLPC_TcHttpdConnection_t* i_inst)
  */\r
 void NyLPC_cHttpdConnection_lock(NyLPC_TcHttpdConnection_t* i_inst)\r
 {\r
-       NyLPC_cHttpd_lock((NyLPC_TcHttpd_t*)(i_inst->_parent_httpd));\r
+    NyLPC_cHttpd_lock((NyLPC_TcHttpd_t*)(i_inst->_parent_httpd));\r
 }\r
 /**\r
  * Httpd全体で唯一のロックを開放する。\r
  */\r
 void NyLPC_cHttpdConnection_unlock(NyLPC_TcHttpdConnection_t* i_inst)\r
 {\r
-       NyLPC_cHttpd_unlock((NyLPC_TcHttpd_t*)(i_inst->_parent_httpd));\r
+    NyLPC_cHttpd_unlock((NyLPC_TcHttpd_t*)(i_inst->_parent_httpd));\r
 }\r