This is Webservice SDK for mbed. LPCXpresso1769/LPC1768/FRDM-K64F/LPC4088

Dependents:   MbedFileServer_1768MiniDK2 RedWireBridge IssueDebug_gcc MiMicRemoteMCU-for-Mbed ... more

libMiMic(MiMic library for mbed)は、WebService機能を提供するSDKです。 mbedでWebAPIに対応したネットワークデバイスを簡単に作ることが出来ます。

libMiMicはMiMic projectで開発しています。MiMic projectについてはこちらをご覧ください。 http://nyatla.jp/mimic/wp/

構成

libMiMicはmbedRTOS上で動作し、ユーザアプリケーションにAPIを提供します。コアAPIはC言語で記述されていますが、使用頻度の高いものについてはmbed向けのC++APIが準備されています。

/media/uploads/nyatla/libmimic-sdk.png

※libMiMicはmbedの標準イーサネットドライバをしようしていません。

標準イーサネットドライバと同時に使用することはできません。

  • MiMicIP - IPv4スタックです。レテンシとメモリ消費量を抑えたuipベースのライブラリです。
  • ARP/ICMP/UDP/TCP - 基礎的なソケットAPIを提供します。APIは独自です。
  • HTTP/1.1 Server - HTTP/1.1に対応したサーバです。マルチセッション・Chunked・持続性接続に対応しています。
  • HTTP Modules - HTTP/1.1の機能モジュールです。以下のモジュールがあります。
    • ROM file provider - ROMに格納したファイルイメージを公開します。
    • File system provider - mbedファイルシステムを公開します。
    • Onchip configuration - プログラムフラッシュを利用して設定を保存します。
    • MiMicVM processor - RPCリクエスト(MiMicVM)を処理します。
    • FileUpload - ファイルアップロードを受け取ります。
    • URL decoder - HTTPリクエストを解析します。
    • UPnP handler -UPnPメッセージを処理します。
    • WebSocket - Websocketサーバです。
  • mDNS - マルチキャストDNSサービスです。
  • UPnP - UPnP/1.0の機能を提供します。UPnP handlerと協調して動作します。(現在はデバイス探索(SSDP)・デスクリプション(Description)のみ実装してあります。)
  • DHCP/APIPA - ゼロコンフィギュレーション用のモジュールです。
  • HTTP/1.1 Client
  • mbed C++ class library - mbed向けのC++CPIです。C言語のものより簡単です。

対応機種

  • mbed(mbed LPC1768)
  • LPCXpresso1769

プログラム

Import programMiMicRemoteMCU-for-Mbed

MiMic RemoteMCU for mbed. This program provides MCU control API over REST API. It can control MCU from Javascript,PHP or any HTTP rest client directly. And, The application has self development environment.

Import programMbedFileServer

The program publishes files at local directory and SD filesystem. It is a full-fledged webServer somewhat.

サンプル

Import programMiMicSimpleHttpd

This is a simplest HTTP server made ​​of libMiMic. It will echo back a request path.

Import programUPnPBasicDevice

Simplest UPnP basic device example. This program to run UPnP basic device on the mbed.

Import programWebSocketSample

MiMicSDK Websocket module sample program.

Import programHttpClientSamlpe

A http client sample program.

Import programTcpSocketClientSamlpe

MiMicSDK Tcp client socket sample program.

Import programUdpSocketSamlpe

Udp socket sample program. This program will send back the received packet.

チュートリアル

English

libMiMic(MiMic library for mbed) is SDK which provides Webservice functions. It can be created networking device easily using mbed.

See more MiMic information, See MiMic project website. http://nyatla.jp/mimic/wp/

Structure

libMiMic run on mbed RTOS and provides networking API to user application. This library has C++ class API for the mbed, and low-level C language API.

/media/uploads/nyatla/libmimic-sdk.png

For WebService general, it can be written in a simple C + + API.

libMiMic does not have the standard Ethernet driver of mbed. It is not possible that will be used with the standard Ethernet driver.

  • MiMicIP - IPv4 protocol stack. This is based uip which is reduced memory and latency.
  • ARP / ICMP / UDP / TCP - Those are provide basic IP protocols.
  • HTTP/1.1 Server - The Http server compatible HTTP/1.1. It supports multi-session, chunked transport, persistent connection.
  • HTTP Modules - There are addon-module for HTTP server. The following modules.
    • ROM file module - Publish the file images in ROM.
    • File system module - Publish thefiles in mbed file system.
    • Onchip configuration module - To save the network settings to the program flash via REST.
    • MiMicVM module - To handle the (MiMicVM) RPC request.
    • FileUpload module - Accept a file via HTTP POST.
    • URL dedoce module - A versatility URL decoder.
    • UPnP handle module - To handle UPnP messages.
    • UPnP - This provides UPnP/1.0 device functions. It works together with UPnP handler.
    • Websocket - websocket (version13) server
  • mDNS Service - DNS-SD protocol server.
  • UPnP - This provides UPnP/1.0 device functions which works with UPnP handler. (You have been implemented (SSDP) ? description only (Description) device search now.) It is a module zero configuration for - DHCP / APIPA. mbed C + + class library - C of mbed for + + is the CPI. It is simple than that of the C language.
  • DHCP/APIPA - It support zero-cpnfigulation.
  • mbed C++ class library. Almost APIs for Web applications are available.
  • HTTP/1.1 Client

Supported target

  • mbed(mbed LPC1768)
  • LPCXpresso1769

Application

Import programMiMicRemoteMCU-for-Mbed

MiMic RemoteMCU for mbed. This program provides MCU control API over REST API. It can control MCU from Javascript,PHP or any HTTP rest client directly. And, The application has self development environment.

Import programMbedFileServer

The program publishes files at local directory and SD filesystem. It is a full-fledged webServer somewhat.

Sample

Import programMiMicSimpleHttpd

This is a simplest HTTP server made ​​of libMiMic. It will echo back a request path.

Import programUPnPBasicDevice

Simplest UPnP basic device example. This program to run UPnP basic device on the mbed.

Import programWebSocketSample

MiMicSDK Websocket module sample program.

Import programHttpClientSamlpe

A http client sample program.

Import programTcpSocketClientSamlpe

MiMicSDK Tcp client socket sample program.

Import programUdpSocketSamlpe

Udp socket sample program. This program will send back the received packet.

Tutorial

Files at this revision

API Documentation at this revision

Comitter:
nyatla
Date:
Tue Jul 09 12:07:17 2013 +0000
Parent:
42:f83aa17dcae5
Child:
44:74390edbe66c
Commit message:
update to r276;

Changed in this revision

core/NyLPC_cMiMicEnv.h Show annotated file Show diff for this revision Revisions of this file
core/http/NyLPC_cHttpStream.c Show annotated file Show diff for this revision Revisions of this file
core/net/httpd/NyLPC_cHttpdConnection.c Show annotated file Show diff for this revision Revisions of this file
core/net/httpd/NyLPC_cHttpdConnection_protected.h Show annotated file Show diff for this revision Revisions of this file
core/net/httpd/NyLPC_cHttpdThread.c Show annotated file Show diff for this revision Revisions of this file
core/net/httpd/NyLPC_cHttpdUtils.c Show annotated file Show diff for this revision Revisions of this file
core/net/httpd/mod/NyLPC_cMocMiMicSetting.c Show annotated file Show diff for this revision Revisions of this file
core/net/httpd/mod/NyLPC_cModFileIoBaseClass.c Show annotated file Show diff for this revision Revisions of this file
core/net/httpd/mod/NyLPC_cModRemoteMcu.c Show annotated file Show diff for this revision Revisions of this file
core/net/httpd/mod/NyLPC_cModRomFiles.c Show annotated file Show diff for this revision Revisions of this file
core/net/httpd/mod/NyLPC_cModUrl.c Show annotated file Show diff for this revision Revisions of this file
core/uip/NyLPC_cIPv4.c Show annotated file Show diff for this revision Revisions of this file
core/uip/NyLPC_cTcpListener.c Show annotated file Show diff for this revision Revisions of this file
core/uip/NyLPC_cTcpListener.h Show annotated file Show diff for this revision Revisions of this file
core/uip/NyLPC_cTcpListener_protected.h Show annotated file Show diff for this revision Revisions of this file
core/uip/NyLPC_cTcpSocket.c Show annotated file Show diff for this revision Revisions of this file
core/uip/NyLPC_cTcpSocket.h Show annotated file Show diff for this revision Revisions of this file
core/uip/NyLPC_cTcpSocket_protected.h Show annotated file Show diff for this revision Revisions of this file
mbed/HttpdConnection.cpp Show annotated file Show diff for this revision Revisions of this file
mbed/HttpdConnection.h Show annotated file Show diff for this revision Revisions of this file
mbed/ModBaseClass.cpp Show diff for this revision Revisions of this file
mbed/ModBaseClass.h Show diff for this revision Revisions of this file
mbed/ModFileIo.cpp Show diff for this revision Revisions of this file
mbed/ModFileIo.h Show diff for this revision Revisions of this file
mbed/ModLocalFileSystem.cpp Show diff for this revision Revisions of this file
mbed/ModLocalFileSystem.h Show diff for this revision Revisions of this file
mbed/ModMiMicSetting.cpp Show diff for this revision Revisions of this file
mbed/ModMiMicSetting.h Show diff for this revision Revisions of this file
mbed/ModRemoteMcu.cpp Show diff for this revision Revisions of this file
mbed/ModRemoteMcu.h Show diff for this revision Revisions of this file
mbed/ModRomFiles.cpp Show diff for this revision Revisions of this file
mbed/ModRomFiles.h Show diff for this revision Revisions of this file
mbed/ModUrl.cpp Show diff for this revision Revisions of this file
mbed/ModUrl.h Show diff for this revision Revisions of this file
mbed/mimic.h Show annotated file Show diff for this revision Revisions of this file
mbed/mod/ModBaseClass.cpp Show annotated file Show diff for this revision Revisions of this file
mbed/mod/ModBaseClass.h Show annotated file Show diff for this revision Revisions of this file
mbed/mod/ModFileIo.cpp Show annotated file Show diff for this revision Revisions of this file
mbed/mod/ModFileIo.h Show annotated file Show diff for this revision Revisions of this file
mbed/mod/ModLocalFileSystem.cpp Show annotated file Show diff for this revision Revisions of this file
mbed/mod/ModLocalFileSystem.h Show annotated file Show diff for this revision Revisions of this file
mbed/mod/ModMiMicSetting.cpp Show annotated file Show diff for this revision Revisions of this file
mbed/mod/ModMiMicSetting.h Show annotated file Show diff for this revision Revisions of this file
mbed/mod/ModRemoteMcu.cpp Show annotated file Show diff for this revision Revisions of this file
mbed/mod/ModRemoteMcu.h Show annotated file Show diff for this revision Revisions of this file
mbed/mod/ModRomFiles.cpp Show annotated file Show diff for this revision Revisions of this file
mbed/mod/ModRomFiles.h Show annotated file Show diff for this revision Revisions of this file
mbed/mod/ModUrl.cpp Show annotated file Show diff for this revision Revisions of this file
mbed/mod/ModUrl.h Show annotated file Show diff for this revision Revisions of this file
--- a/core/NyLPC_cMiMicEnv.h	Thu Jul 04 11:05:56 2013 +0000
+++ b/core/NyLPC_cMiMicEnv.h	Tue Jul 09 12:07:17 2013 +0000
@@ -13,7 +13,7 @@
 #endif /* __cplusplus */
 
 
-#define NyLPC_cMiMicEnv_VERSION "MiMic/1.4.20"
+#define NyLPC_cMiMicEnv_VERSION "MiMic/1.4.22"
 
 
 #ifdef __cplusplus
--- a/core/http/NyLPC_cHttpStream.c	Thu Jul 04 11:05:56 2013 +0000
+++ b/core/http/NyLPC_cHttpStream.c	Tue Jul 09 12:07:17 2013 +0000
@@ -77,7 +77,7 @@
 /**
  * HTTP送受信のタイムアウト値
  */
-#define HTTP_TIMEOUT 10*1000
+#define HTTP_TIMEOUT 5*1000
 /**
  * HTTP送信バッファのヒント値
  */
--- a/core/net/httpd/NyLPC_cHttpdConnection.c	Thu Jul 04 11:05:56 2013 +0000
+++ b/core/net/httpd/NyLPC_cHttpdConnection.c	Tue Jul 09 12:07:17 2013 +0000
@@ -209,10 +209,6 @@
     }
     return NyLPC_TBool_TRUE;
 }
-void NyLPC_cHttpdConnection_setConnectionMode(NyLPC_TcHttpdConnection_t* i_inst,NyLPC_TcHttpdConnection_CONNECTION_MODE i_mode)
-{
-    i_inst->_connection_message_mode=i_mode;
-}
 
 /**
  * コネクションのプリフェッチデータをヘッダパーサへpushします。
@@ -271,7 +267,7 @@
     //初回だけHEADに遷移
     i_inst->_res_status=NyLPC_cHttpdConnection_ResStatus_HEAD;
     i_inst->_req_status=NyLPC_cHttpdConnection_ReqStatus_PREFETCH;
-    i_inst->_connection_message_mode=NyLPC_TcHttpdConnection_CONNECTION_MODE_CONTINUE;
+    i_inst->_connection_message_mode=NyLPC_TcHttpdConnection_CONNECTION_MODE_CLOSE;
     return NyLPC_TBool_TRUE;
 Error_Connected:
     NyLPC_cTcpSocket_close(&(i_inst->_socket),NyLPC_cHttpdConnection_TIMEOUT_CLOSE);
--- a/core/net/httpd/NyLPC_cHttpdConnection_protected.h	Thu Jul 04 11:05:56 2013 +0000
+++ b/core/net/httpd/NyLPC_cHttpdConnection_protected.h	Tue Jul 09 12:07:17 2013 +0000
@@ -94,8 +94,7 @@
  * HTTPリクエストのバージョンが1.1かつconnectionがCLOSEで無い場合、CONTINUEを指定することで持続性接続に設定できる。
  * 関数は、NyLPC_cHttpdConnection_sendResponseHeaderをコールする前に実行すること。
  */
-void NyLPC_cHttpdConnection_setConnectionMode(NyLPC_TcHttpdConnection_t* i_inst,NyLPC_TcHttpdConnection_CONNECTION_MODE i_mode);
-
+#define NyLPC_cHttpdConnection_setConnectionMode(i_inst,i_mode)     (i_inst)->_connection_message_mode=(i_mode)
 
 NyLPC_TUInt16 NyLPC_cHttpd_incNumOfConnection(NyLPC_TcHttpd_t* i_inst);
 NyLPC_TUInt16 NyLPC_cHttpd_decNumOfConnection(NyLPC_TcHttpd_t* i_inst);
--- a/core/net/httpd/NyLPC_cHttpdThread.c	Thu Jul 04 11:05:56 2013 +0000
+++ b/core/net/httpd/NyLPC_cHttpdThread.c	Tue Jul 09 12:07:17 2013 +0000
@@ -56,17 +56,15 @@
             //Prefetch出来ないならループ終了。
             break;
         }
-        //コネクションをクローズにリセット
-        NyLPC_cHttpdConnection_setConnectionMode(inst,NyLPC_TcHttpdConnection_CONNECTION_MODE_CLOSE);
-
+        //持続性接続の初期モードを設定
+        if(NyLPC_cHttpd_getNumOfConnection(inst->_parent_httpd)>LIMIT_OF_PERSISTENT_CONNECTION){
+            NyLPC_cHttpdConnection_setConnectionMode(inst,NyLPC_TcHttpdConnection_CONNECTION_MODE_CLOSE);
+        }else{
+            NyLPC_cHttpdConnection_setConnectionMode(inst,NyLPC_TcHttpdConnection_CONNECTION_MODE_CONTINUE);
+        }
         {//handler
             (inst->_parent_httpd->function.onRequest)(inst);
         }
-        //@bug onRequest後だとHTTPヘッダには効果がない。強制的にConnectionModeをCloseにするフラグが必要。
-        //コネクションが増えすぎたら持続性接続を停止するためにCLOSEDにする。
-        if(NyLPC_cHttpd_getNumOfConnection(inst->_parent_httpd)>LIMIT_OF_PERSISTENT_CONNECTION){
-            NyLPC_cHttpdConnection_setConnectionMode(inst,NyLPC_TcHttpdConnection_CONNECTION_MODE_CLOSE);
-        }
         //HTTP層のクローズ
         if(!NyLPC_cHttpdConnection_closeResponse(inst)){
             break;
--- a/core/net/httpd/NyLPC_cHttpdUtils.c	Thu Jul 04 11:05:56 2013 +0000
+++ b/core/net/httpd/NyLPC_cHttpdUtils.c	Tue Jul 09 12:07:17 2013 +0000
@@ -35,6 +35,8 @@
 void NyLPC_cHttpdUtils_sendErrorResponse(NyLPC_TcHttpdConnection_t* i_connection,int i_status)
 {
     NyLPC_TUInt8 mt=NyLPC_cHttpdConnection_getMethod(i_connection);
+    //ConnectionをCLOSEへセット
+    NyLPC_cHttpdConnection_setConnectionMode(i_connection,NyLPC_TcHttpdConnection_CONNECTION_MODE_CLOSE);
     NyLPC_cHttpdConnection_sendResponseHeader(i_connection,i_status,"text/html",NULL);
     if(mt!=NyLPC_THttpMethodType_HEAD){
         NyLPC_cHttpdConnection_sendResponseBodyF(i_connection,"<!DOCTYPE html><html><head><title>MiMicHTTPD</title></head><body>Status %d</body></html>",i_status);
--- a/core/net/httpd/mod/NyLPC_cMocMiMicSetting.c	Thu Jul 04 11:05:56 2013 +0000
+++ b/core/net/httpd/mod/NyLPC_cMocMiMicSetting.c	Tue Jul 09 12:07:17 2013 +0000
@@ -351,10 +351,10 @@
         NyLPC_cHttpdUtils_sendErrorResponse(i_connection,405);
         NyLPC_OnErrorGoto(Error2);
     }
-    //Connection Modeの設定 1.1 && !closeの場合はCONTINUE
-    if(header.super.connection!=NyLPC_THttpMessgeHeader_Connection_CLOSE && header.super.startline.req.version==NyLPC_THttpVersion_11)
+    //Request::ConnectionがClose設定,又はHTTP1.1では無い場合,CLOSE
+    if(header.super.connection==NyLPC_THttpMessgeHeader_Connection_CLOSE || header.super.startline.req.version!=NyLPC_THttpVersion_11)
     {
-        NyLPC_cHttpdConnection_setConnectionMode(i_connection,NyLPC_TcHttpdConnection_CONNECTION_MODE_CONTINUE);
+        NyLPC_cHttpdConnection_setConnectionMode(i_connection,NyLPC_TcHttpdConnection_CONNECTION_MODE_CLOSE);
     }
     //CGIの実行
     switch(header._content_id)
--- a/core/net/httpd/mod/NyLPC_cModFileIoBaseClass.c	Thu Jul 04 11:05:56 2013 +0000
+++ b/core/net/httpd/mod/NyLPC_cModFileIoBaseClass.c	Tue Jul 09 12:07:17 2013 +0000
@@ -273,10 +273,10 @@
         NyLPC_cUrlEncode_finalize(&single_header.urlencode);
         NyLPC_cStr_finalize(&single_header._tstr);
     }
-    //Connection Modeの設定 1.1 && !closeの場合はCONTINUE
-    if(single_header.super.connection!=NyLPC_THttpMessgeHeader_Connection_CLOSE && single_header.super.startline.req.version==NyLPC_THttpVersion_11)
+    //Request::ConnectionがClose設定,又はHTTP1.1では無い場合,CLOSE
+    if(single_header.super.connection==NyLPC_THttpMessgeHeader_Connection_CLOSE || single_header.super.startline.req.version!=NyLPC_THttpVersion_11)
     {
-        NyLPC_cHttpdConnection_setConnectionMode(i_connection,NyLPC_TcHttpdConnection_CONNECTION_MODE_CONTINUE);
+        NyLPC_cHttpdConnection_setConnectionMode(i_connection,NyLPC_TcHttpdConnection_CONNECTION_MODE_CLOSE);
     }
     //返答フェーズ
     {
--- a/core/net/httpd/mod/NyLPC_cModRemoteMcu.c	Thu Jul 04 11:05:56 2013 +0000
+++ b/core/net/httpd/mod/NyLPC_cModRemoteMcu.c	Tue Jul 09 12:07:17 2013 +0000
@@ -379,10 +379,10 @@
         NyLPC_cHttpdUtils_sendErrorResponse(i_connection,405);
         NyLPC_OnErrorGoto(Error1);
     }
-    //Connection Modeの設定 1.1 && !closeの場合はCONTINUE
-    if(single_header.super.connection!=NyLPC_THttpMessgeHeader_Connection_CLOSE && single_header.super.startline.req.version==NyLPC_THttpVersion_11)
+    //Request::ConnectionがClose設定,又はHTTP1.1では無い場合,CLOSE
+    if(single_header.super.connection==NyLPC_THttpMessgeHeader_Connection_CLOSE || single_header.super.startline.req.version!=NyLPC_THttpVersion_11)
     {
-        NyLPC_cHttpdConnection_setConnectionMode(i_connection,NyLPC_TcHttpdConnection_CONNECTION_MODE_CONTINUE);
+        NyLPC_cHttpdConnection_setConnectionMode(i_connection,NyLPC_TcHttpdConnection_CONNECTION_MODE_CLOSE);
     }
     //CGIの実行
     switch(single_header._content_id)
--- a/core/net/httpd/mod/NyLPC_cModRomFiles.c	Thu Jul 04 11:05:56 2013 +0000
+++ b/core/net/httpd/mod/NyLPC_cModRomFiles.c	Tue Jul 09 12:07:17 2013 +0000
@@ -110,10 +110,10 @@
         if(strcmp(url,i_inst->_data[i].name)!=0){
             continue;
         }
-        //Connection Modeの設定 1.1 && !closeの場合はCONTINUE
-        if(i_inst->super._header.connection!=NyLPC_THttpMessgeHeader_Connection_CLOSE && i_inst->super._header.startline.req.version==NyLPC_THttpVersion_11)
+        //Request::ConnectionがClose設定,又はHTTP1.1では無い場合,CLOSE
+        if(i_inst->super._header.connection==NyLPC_THttpMessgeHeader_Connection_CLOSE || i_inst->super._header.startline.req.version!=NyLPC_THttpVersion_11)
         {
-            NyLPC_cHttpdConnection_setConnectionMode(i_connection,NyLPC_TcHttpdConnection_CONNECTION_MODE_CONTINUE);
+            NyLPC_cHttpdConnection_setConnectionMode(i_connection,NyLPC_TcHttpdConnection_CONNECTION_MODE_CLOSE);
         }
         return NyLPC_cHttpdUtils_sendFixedContentBatch(i_connection,i_inst->_data[i].content_type,i_inst->_data[i].data,i_inst->_data[i].size>0?i_inst->_data[i].size:strlen(i_inst->_data[i].data));
     }
--- a/core/net/httpd/mod/NyLPC_cModUrl.c	Thu Jul 04 11:05:56 2013 +0000
+++ b/core/net/httpd/mod/NyLPC_cModUrl.c	Tue Jul 09 12:07:17 2013 +0000
@@ -133,7 +133,7 @@
     parser.length_of_url=-i_pass_prefix_len;//無視するPrefix長
     parser.skip=(parser.length_of_url<0)?NyLPC_TUInt8_TRUE:NyLPC_TUInt8_FALSE;//スキップの初期値の設定
     parser.url_buf=o_url_buf;
-    parser.url_buf[0]='0';//URL長<=prefix長に備えてNULLターミネイト
+    parser.url_buf[0]='\0';//URL長<=prefix長に備えてNULLターミネイト
     parser.reason=400;
     parser.mode=i_mode;
     //プリフェッチしたデータを流す
@@ -146,18 +146,19 @@
     if(!NyLPC_cHttpBasicHeaderParser_parseFinish(&parser.super,&(i_inst->_header))){
         NyLPC_OnErrorGoto(Error2);
     }
+    //@todo http/1.1 && POSTの場合はcontinueを送る。
     if(i_inst->_header.startline.req.version==NyLPC_THttpVersion_11){
-        //Connection Modeの設定 1.1 && !closeの場合はCONTINUE
-        if(i_inst->_header.connection!=NyLPC_THttpMessgeHeader_Connection_CLOSE)
-        {
-            NyLPC_cHttpdConnection_setConnectionMode(i_connection,NyLPC_TcHttpdConnection_CONNECTION_MODE_CONTINUE);
-        }
-        //@todo http/1.1 && POSTの場合はcontinueを送る。
         if(i_inst->_header.startline.req.method==NyLPC_THttpMethodType_POST)
         {
             NyLPC_cHttpdConnection_send100Continue(i_connection);
         }
     }
+    //Request::ConnectionがClose設定,又はHTTP1.1では無い場合,CLOSE
+    if(i_inst->_header.connection==NyLPC_THttpMessgeHeader_Connection_CLOSE || i_inst->_header.startline.req.version!=NyLPC_THttpVersion_11)
+    {
+        NyLPC_cHttpdConnection_setConnectionMode(i_connection,NyLPC_TcHttpdConnection_CONNECTION_MODE_CLOSE);
+    }
+
     NyLPC_cHttpBasicHeaderParser_finalize(&parser);
     //BodyParserの初期化
     if(NyLPC_cHttpBodyParser_getState(&i_inst->_body_parser)!=NyLPC_TcHttpBasicBodyParser_ST_NULL){
--- a/core/uip/NyLPC_cIPv4.c	Thu Jul 04 11:05:56 2013 +0000
+++ b/core/uip/NyLPC_cIPv4.c	Tue Jul 09 12:07:17 2013 +0000
@@ -151,9 +151,9 @@
 }
 
 /**
- * i_peer番号に一致するリスナを返します。
+ * i_port番号に一致するリスナを返します。
  */
-static NyLPC_TcTcpListener_t* cSocketTbl_getListenerByPeerPort(NyLPC_TcPtrTbl_t* i_inst,NyLPC_TUInt16 i_peer_port)
+static NyLPC_TcTcpListener_t* cSocketTbl_getListenerByPeerPort(NyLPC_TcPtrTbl_t* i_inst,NyLPC_TUInt16 i_port)
 {
     NyLPC_TcBaseSocket_t** p=(NyLPC_TcBaseSocket_t**)(i_inst->buf);
     NyLPC_TcTcpListener_t* lp;
@@ -164,7 +164,7 @@
             continue;
         }
         lp=(NyLPC_TcTcpListener_t*)p[i];
-        if(lp->_port!=i_peer_port){
+        if(lp->_port!=i_port){
             continue;
         }
         return lp;
@@ -449,11 +449,7 @@
             return NyLPC_TBool_TRUE;
         }
         //リスナにソケットのバインドを依頼する。
-        sock=NyLPC_cTcpListener_makeSynRcvdSocket(listener,i_ipp);
-        if(sock==NULL){
-            //Listen失敗。ドロップ
-            goto DROP;
-        }
+        NyLPC_cTcpListener_synPacket(listener,i_ipp);
         return NyLPC_TBool_FALSE;//LISTEN成功。送信データなし
     }
     return NyLPC_TBool_TRUE;
--- a/core/uip/NyLPC_cTcpListener.c	Thu Jul 04 11:05:56 2013 +0000
+++ b/core/uip/NyLPC_cTcpListener.c	Tue Jul 09 12:07:17 2013 +0000
@@ -28,6 +28,75 @@
 #include "NyLPC_cUipService_protected.h"
 #include "NyLPC_cIPv4.h"
 #include "NyLPC_stdlib.h"
+#include <stdio.h>
+/**
+ * NyLPC_TTcpListenerListenQ
+ */
+
+void NyLPC_TTcpListenerListenQ_init(struct NyLPC_TTcpListenerListenQ* i_struct)
+{
+    i_struct->wp=0;
+    int i;
+    for(i=NyLPC_TcTcpListener_NUMBER_OF_Q-1;i>=0;i--){
+        i_struct->item[i].rport=0;
+    }
+}
+
+/**
+ * ListenQへSYNパケットの情報を追加する。
+ */
+void NyLPC_TTcpListenerListenQ_add(struct NyLPC_TTcpListenerListenQ* i_struct,const NyLPC_TcIPv4Payload_t* i_payload)
+{
+    struct NyLPC_TTcpSocketSynParam* item=&i_struct->item[i_struct->wp];
+    //未処理のものがあれば登録しない。
+    if(item->rport!=0){
+        return;
+    }
+
+    //SYNリングバッファにセット
+    item->rport = i_payload->payload.tcp->srcport;
+    item->srcaddr=i_payload->header->srcipaddr;
+    item->rcv_nxt32=NyLPC_ntohl(i_payload->payload.tcp->seqno32)+1;
+    //MSSの設定
+    if(!NyLPC_TTcpHeader_getTcpMmsOpt(i_payload->payload.tcp,&item->mss)){
+        item->mss=0;
+    }
+    //書込み位置の進行
+    i_struct->wp=(i_struct->wp+1)%NyLPC_TcTcpListener_NUMBER_OF_Q;
+}
+
+/**
+ * 最も古いSYNパケット情報のインデクスをキューから返す。
+ * @return
+ * 見つからない場合-1である。
+ */
+int NyLPC_TTcpListenerListenQ_getLastIndex(struct NyLPC_TTcpListenerListenQ* i_struct)
+{
+    int i,t;
+    //古いものから順に返す
+    for(i=1;i<=NyLPC_TcTcpListener_NUMBER_OF_Q;i++){
+        t=(i_struct->wp+i)%NyLPC_TcTcpListener_NUMBER_OF_Q;
+        //有効なデータ?
+        if(i_struct->item[t].rport!=0){
+            return t;
+        }
+    }
+    return -1;
+}
+
+/**
+ * ListenQのN番目を削除する。
+ */
+void NyLPC_TTcpListenerListenQ_remove(struct NyLPC_TTcpListenerListenQ* i_struct,int i_idx)
+{
+    i_struct->item[i_idx].rport=0;
+    return;
+}
+
+
+
+
+
 
 
 #define lockResource(i_inst) NyLPC_cMutex_lock(((i_inst)->_mutex))
@@ -41,14 +110,13 @@
 {
     NyLPC_TcUipService_t* srv=_NyLPC_TcUipService_inst;
     NyLPC_cBaseSocket_initialize(&(i_inst->_super),NyLPC_TcBaseSocket_TYPEID_TCP_LISTENER);
-
+    NyLPC_TTcpListenerListenQ_init(&i_inst->_listen_q);
     //uipサービスは初期化済であること。
     NyLPC_Assert(NyLPC_TcUipService_isInitService());
     //初期化
     //  NyLPC_cMutex_initialize(&(i_inst->_mutex));
     i_inst->_mutex=NyLPC_cIPv4_getListenerMutex(&srv->_tcpv4);//    NyLPC_cMutex_initialize(&(i_inst->_mutex));
     i_inst->_port=NyLPC_htons(i_port);
-    i_inst->_ref_sock=NULL;
     //管理リストへ登録。
     return NyLPC_cIPv4_addSocket(&(srv->_tcpv4),&(i_inst->_super));
 }
@@ -66,10 +134,14 @@
     return;
 }
 
+
+
+
 NyLPC_TBool NyLPC_cTcpListener_listen(NyLPC_TcTcpListener_t* i_inst,NyLPC_TcTcpSocket_t* i_sock,NyLPC_TUInt32 i_wait_msec)
 {
+    int qi;
     NyLPC_TcStopwatch_t sw;
-    NyLPC_TBool ret;
+    NyLPC_TBool ret=NyLPC_TBool_FALSE;
     //サービスは稼働中であること。
     NyLPC_Assert(NyLPC_cUipService_isRun());
 
@@ -77,64 +149,62 @@
     if(i_sock->tcpstateflags!=UIP_CLOSED){
         return NyLPC_TBool_FALSE;
     }
-    //Listenerのリソースロック
-    lockResource(i_inst);
-    //listenターゲットのセット
-    i_inst->_ref_sock=i_sock;
-    //Listenerのリソースアンロック
-    unlockResource(i_inst);
 
-
-    //一定時間待つ。
+    //ストップウォッチを起動
     NyLPC_cStopwatch_initialize(&sw);
     NyLPC_cStopwatch_setNow(&sw);
-    while(NyLPC_cStopwatch_elapseInMsec(&sw)<i_wait_msec){
-        NyLPC_cThread_yield();
-        //ステータス遷移が実行されていたら、ブレーク
-        if(i_inst->_ref_sock->tcpstateflags==UIP_SYN_RCVD){
-            break;
-        }
-    }
-    NyLPC_cStopwatch_finalize(&sw);
+
 
     //Listenerのリソースロック
     lockResource(i_inst);
-    //受領確認と戻り値の決定
-    if(i_inst->_ref_sock->tcpstateflags==UIP_SYN_RCVD){
-        ret=NyLPC_TBool_TRUE;
-    }else{
-        ret=NyLPC_TBool_FALSE;
+
+    while(NyLPC_cStopwatch_elapseInMsec(&sw)<i_wait_msec){
+        qi=NyLPC_TTcpListenerListenQ_getLastIndex(&i_inst->_listen_q);
+        if(qi>=0){
+            //SYN処理要求がある
+            if(!NyLPC_cTcpSocket_listenSyn(i_sock,&i_inst->_listen_q.item[qi],i_inst->_port)){
+                ret=NyLPC_TBool_FALSE;
+            }else{
+                //成功
+                ret=NyLPC_TBool_TRUE;
+            }
+            //処理したSYNの削除
+            NyLPC_TTcpListenerListenQ_remove(&i_inst->_listen_q,qi);
+            break;
+        }else{
+            //SYN処理要求は無い(しばらくまつ)
+            unlockResource(i_inst);
+            NyLPC_cThread_yield();
+            lockResource(i_inst);
+        }
     }
-    //バインドしてあるソケットを解除
-    i_inst->_ref_sock=NULL;
-    //Listenerのリソースアンロック
+    //タイムアウト
     unlockResource(i_inst);
+    NyLPC_cStopwatch_finalize(&sw);
     return ret;
 }
 
 /**
  * この関数は、Uip受信タスクから実行します。
  */
-NyLPC_TcTcpSocket_t* NyLPC_cTcpListener_makeSynRcvdSocket(NyLPC_TcTcpListener_t* i_inst,const NyLPC_TcIPv4Payload_t* i_payload)
+NyLPC_TBool NyLPC_cTcpListener_synPacket(NyLPC_TcTcpListener_t* i_inst,const NyLPC_TcIPv4Payload_t* i_payload)
 {
-    NyLPC_TcTcpSocket_t* sock=NULL;
     //パケットチェック。SYN設定されてる?
     if(!(i_payload->payload.tcp->flags & TCP_SYN)){
         //SYNない
-        return NULL;
+        return NyLPC_TBool_FALSE;
+    }
+    //peer port==0は受け取らない。
+    if(i_payload->payload.tcp->srcport==0){
+        return NyLPC_TBool_FALSE;
     }
     //Listenerのリソースロック
     lockResource(i_inst);
-    if(i_inst->_ref_sock!=NULL){
-        //listenターゲットが指定されていたら、ソケットステータスの遷移。CLOSED->SYN_RCVD
-        if(NyLPC_cTcpSocket_setSynPayload(i_inst->_ref_sock,i_payload))
-        {
-            sock=i_inst->_ref_sock;
-        }
-    }
+    //ListenQへ追加
+    NyLPC_TTcpListenerListenQ_add(&(i_inst->_listen_q),i_payload);
     //Listenerのリソースアンロック
     unlockResource(i_inst);
-    return sock;
+    return NyLPC_TBool_TRUE;
 }
 
 
--- a/core/uip/NyLPC_cTcpListener.h	Thu Jul 04 11:05:56 2013 +0000
+++ b/core/uip/NyLPC_cTcpListener.h	Tue Jul 09 12:07:17 2013 +0000
@@ -26,21 +26,37 @@
 #ifndef NYLPC_CTCPLISTENER_H_
 #define NYLPC_CTCPLISTENER_H_
 
-typedef struct NyLPC_TcTcpListener NyLPC_TcTcpListener_t;
-
 
 #include "NyLPC_stdlib.h"
 #include "NyLPC_os.h"
 #include "NyLPC_cBaseSocket.h"
 #include "NyLPC_cTcpSocket.h"
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+typedef struct NyLPC_TcTcpListener NyLPC_TcTcpListener_t;
+
+/**********************************************************************
+ *
+ * NyLPC_TTcpListenerListenQ struct
+ *
+ **********************************************************************/
+
+#define NyLPC_TcTcpListener_NUMBER_OF_Q 10
+
+struct NyLPC_TTcpListenerListenQ
+{
+    struct NyLPC_TTcpSocketSynParam item[NyLPC_TcTcpListener_NUMBER_OF_Q];
+    NyLPC_TUInt16 wp;
+};
+
+
 /**********************************************************************
  *
  * NyLPC_TcTcpListener class
  *
  **********************************************************************/
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
 
 /**
  * TCP listenerクラス型です。
@@ -49,12 +65,15 @@
 {
     NyLPC_TcBaseSocket_t _super;
     NyLPC_TUInt16 _port;                /**<ネットワークオーダーのポート番号*/
-    /** バインドするためのソケット*/
-    NyLPC_TcTcpSocket_t* _ref_sock;
-    /** タスク間の調停用Mutex
+    /**
+     * タスク間の調停用Mutex
      * Listener用の共通Mutexポインタ
      */
     NyLPC_TcMutex_t* _mutex;
+    /**
+     * SYNパケットのキュー
+     */
+    struct NyLPC_TTcpListenerListenQ _listen_q;
 };
 /**
  * この関数は、TCPのリスナーを初期化します。
--- a/core/uip/NyLPC_cTcpListener_protected.h	Thu Jul 04 11:05:56 2013 +0000
+++ b/core/uip/NyLPC_cTcpListener_protected.h	Tue Jul 09 12:07:17 2013 +0000
@@ -23,35 +23,87 @@
  *  <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
  *
  *********************************************************************************/
-#ifndef NYLPC_CTCPLISTENER_PROTECTED_H_
-#define NYLPC_CTCPLISTENER_PROTECTED_H_
-#include "NyLPC_cTcpListener.h"
-#include "NyLPC_cUipService_protected.h"
 
+#ifndef NYLPC_CTCPSOCKET_PROTECTED_H_
+#define NYLPC_CTCPSOCKET_PROTECTED_H_
+#include "NyLPC_cIPv4.h"
+#include "NyLPC_cTcpSocket.h"
+#include "NyLPC_cIPv4Config.h"
+#include "NyLPC_cIPv4Payload_protected.h"
 #ifdef __cplusplus
 extern "C" {
 #endif /* __cplusplus */
 
-/*protected*/
-
 /**********************************************************************
  * ステータス値の定義
  **********************************************************************/
+#define UIP_CLOSED       0
+#define UIP_SYN_RCVD     1
+#define UIP_SYN_SENT     2
+#define UIP_ESTABLISHED  3
+#define UIP_FIN_WAIT_1   4
+#define UIP_FIN_WAIT_2   5
+#define UIP_CLOSING      6
+#define UIP_TIME_WAIT    7
+#define UIP_CLOSE_WAIT   8
+#define UIP_LAST_ACK     9
 
-/**アイドル状態*/
-#define NyLPC_TcTcpListener_STATUS_NULL     0x00
-/**アイドル状態*/
-#define NyLPC_TcTcpListener_STATUS_IDLE     0x01
-/**uipコアタスクに対して、バインド機会を求めている.*/
-#define NyLPC_TcTcpListener_STATUS_REQ_BIND 0x02
+
+
+
 
 
 
 
-NyLPC_TcTcpSocket_t* NyLPC_cTcpListener_makeSynRcvdSocket(NyLPC_TcTcpListener_t* i_inst,const NyLPC_TcIPv4Payload_t* i_payload);
+/**
+ * パース結果をもとに、ソケットのuipconnectionを初期化します。
+ * この関数は、cUipServiceからのみコールできます。
+ */
+void NyLPC_cTcpSocket_initConnection(NyLPC_TcTcpSocket_t* i_inst,const NyLPC_TcIPv4Config_t* i_config,const NyLPC_TcIPv4Payload_t* i_ipp);
+
+/**
+ * TCPペイロードを処理して、応答パケットをペイロードに返します。
+ * uipサービスタスクが実行する関数です。
+ * @return
+ * 応答ペイロードの有無を返します。
+ */
+NyLPC_TBool NyLPC_cTcpSocket_parseRx(
+    NyLPC_TcTcpSocket_t* i_inst,
+    NyLPC_TcIPv4Payload_t* o_ipp);
+
+/**
+ * 定期的に実行する関数。最低でも1s単位で実行してください。
+ * uipサービスタスクが実行する関数です。
+ */
+void NyLPC_cTcpSocket_periodic(
+    NyLPC_TcTcpSocket_t* i_inst);
+
+/**
+ * CLOSEステータスのソケットを、SYN情報の内容でSYNRECV状態にします。
+ * この関数は、NyLPC_TcTcpListenerクラスからコールされます。
+ * @return
+ * 遷移に成功すると、TRUEを返します。
+ */
+NyLPC_TBool NyLPC_cTcpSocket_listenSyn(NyLPC_TcTcpSocket_t* i_inst,const struct NyLPC_TTcpSocketSynParam* i_lq,NyLPC_TUInt16 i_lport);
+
+
+/**
+ * uipサービスタスクが実行する関数です。
+ * サービスの開始を通知します。
+ * この関数は他のAPIが非同期に実行されないことが保証される状況で使用する必要があります。
+ */
+void NyLPC_cTcpSocket_startService(NyLPC_TcTcpSocket_t* i_inst,const NyLPC_TcIPv4Config_t* i_config);
+
+/**
+ * uipサービスタスクが実行する関数です。
+ * サービスの停止を通知します。
+ * この関数は他のAPIが非同期に実行されないことが保証される状況で使用する必要があります。
+ */
+void NyLPC_cTcpSocket_stopService(NyLPC_TcTcpSocket_t* i_inst);
+
 
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
 
-#endif /* NYLPC_CTCPLISTENER_PROTECTED_H_ */
+#endif /* NYLPC_CTCPSOCKET_PROTECTED_H_ */
--- a/core/uip/NyLPC_cTcpSocket.c	Thu Jul 04 11:05:56 2013 +0000
+++ b/core/uip/NyLPC_cTcpSocket.c	Tue Jul 09 12:07:17 2013 +0000
@@ -346,9 +346,9 @@
 }
 
 
-NyLPC_TBool NyLPC_cTcpSocket_setSynPayload(NyLPC_TcTcpSocket_t* i_inst,const NyLPC_TcIPv4Payload_t* i_ipp)
+
+NyLPC_TBool NyLPC_cTcpSocket_listenSyn(NyLPC_TcTcpSocket_t* i_inst,const struct NyLPC_TTcpSocketSynParam* i_lq,NyLPC_TUInt16 i_lport)
 {
-    NyLPC_TUInt16 tmp16;
 //  NyLPC_Assert(NyLPC_cMutex_isLocked(i_inst->_smutex));
     lockResource(i_inst);
     //ソケットが無効であること。
@@ -357,16 +357,16 @@
         //localipとdefault_mmsは別枠で設定
         /* Fill in the necessary fields for the new connection. */
         i_inst->uip_connr.current_rto32 = UIP_IP_RTOP_INITIAL;
-        i_inst->uip_connr.lport = i_ipp->payload.tcp->destport;
-        i_inst->uip_connr.rport = i_ipp->payload.tcp->srcport;
-        i_inst->uip_connr.ripaddr=i_ipp->header->srcipaddr;
+        i_inst->uip_connr.lport = i_lport;
+        i_inst->uip_connr.rport = i_lq->rport;
+        i_inst->uip_connr.ripaddr=i_lq->srcaddr;
         i_inst->uip_connr.snd_nxt32=iss32;
         /* rcv_nxt should be the seqno from the incoming packet + 1. */
-        i_inst->uip_connr.rcv_nxt32= NyLPC_ntohl(i_ipp->payload.tcp->seqno32)+1;
+        i_inst->uip_connr.rcv_nxt32= i_lq->rcv_nxt32;
         //MSSの設定
         i_inst->uip_connr.peer_mss=i_inst->uip_connr.default_mss;
-        if(NyLPC_TTcpHeader_getTcpMmsOpt(i_ipp->payload.tcp,&tmp16)){
-            i_inst->uip_connr.peer_mss=tmp16;
+        if(i_lq->mss!=0){
+            i_inst->uip_connr.peer_mss=i_lq->mss;
         }
         i_inst->uip_connr.peer_win=0;
         NyLPC_cFifoBuffer_clear(&(i_inst->rxbuf));
@@ -383,6 +383,8 @@
     unlockResource(i_inst);
     return NyLPC_TBool_FALSE;
 }
+
+
 /**
  * sq番のTxがキューから消え去るのを待ちます。
  * この関数は、アンロック状態でコールしてください。
@@ -1036,7 +1038,6 @@
     NyLPC_cStopwatch_finalize(&sw);
     return;
 }
-void led(int i);
 /**
  * uipサービスタスクが実行する関数です。
  * サービスの開始を通知します。
@@ -1044,7 +1045,7 @@
 void NyLPC_cTcpSocket_startService(NyLPC_TcTcpSocket_t* i_inst,const NyLPC_TcIPv4Config_t* i_config)
 {
     NyLPC_Assert(i_inst->tcpstateflags==UIP_CLOSED);//閉じてなければおかしい。
-    i_inst->uip_connr.lipaddr=&(i_config->ip_addr); 
+    i_inst->uip_connr.lipaddr=&(i_config->ip_addr);
     i_inst->uip_connr.default_mss=i_config->default_mss;
     //NyLPC_cTcpSocket_setSynPayload関数でも実行するけど、IFのリセット時なのでここでもやる。
     NyLPC_cFifoBuffer_clear(&(i_inst->rxbuf));
--- a/core/uip/NyLPC_cTcpSocket.h	Thu Jul 04 11:05:56 2013 +0000
+++ b/core/uip/NyLPC_cTcpSocket.h	Tue Jul 09 12:07:17 2013 +0000
@@ -41,6 +41,29 @@
 
 typedef struct NyLPC_TcTcpSocket NyLPC_TcTcpSocket_t;
 
+
+/**********************************************************************
+ *
+ * NyLPC_TTcpListenerSynInfo struct
+ *
+ **********************************************************************/
+
+
+struct NyLPC_TTcpSocketSynParam
+{
+    struct NyLPC_TIPv4Addr srcaddr;
+    NyLPC_TUInt16 rport;
+    NyLPC_TUInt16 mss;
+    NyLPC_TUInt32 rcv_nxt32;
+};
+
+
+/**********************************************************************
+ *
+ * NyLPC_TcTcpSocket_TxQItem struct
+ *
+ **********************************************************************/
+
 /**
  * TXキューの数。この値は8未満にしてください。
  */
@@ -57,6 +80,12 @@
     NyLPC_TUInt32 ackno;
 };
 
+/**********************************************************************
+ *
+ * uip_conn struct
+ *
+ **********************************************************************/
+
 struct uip_conn
 {
     struct NyLPC_TIPv4Addr        ripaddr;  /**< The IP address of the remote host. */
--- a/core/uip/NyLPC_cTcpSocket_protected.h	Thu Jul 04 11:05:56 2013 +0000
+++ b/core/uip/NyLPC_cTcpSocket_protected.h	Tue Jul 09 12:07:17 2013 +0000
@@ -79,14 +79,13 @@
     NyLPC_TcTcpSocket_t* i_inst);
 
 /**
- * uipサービスタスクが実行する関数です。
- * uipコアタスクが実行します。
- * コール前に共有MUTEXにロックをかけてください。
- * ソケットを、SYNパケットで初期化して、UIP_SYN_RECV状態にします。
+ * CLOSEステータスのソケットを、SYN情報の内容でSYNRECV状態にします。
+ * この関数は、NyLPC_TcTcpListenerクラスからコールされます。
  * @return
  * 遷移に成功すると、TRUEを返します。
  */
-NyLPC_TBool NyLPC_cTcpSocket_setSynPayload(NyLPC_TcTcpSocket_t* i_inst,const NyLPC_TcIPv4Payload_t* i_ipp);
+NyLPC_TBool NyLPC_cTcpSocket_listenSyn(NyLPC_TcTcpSocket_t* i_inst,const struct NyLPC_TTcpSocketSynParam* i_lq,NyLPC_TUInt16 i_lport);
+
 
 /**
  * uipサービスタスクが実行する関数です。
--- a/mbed/HttpdConnection.cpp	Thu Jul 04 11:05:56 2013 +0000
+++ b/mbed/HttpdConnection.cpp	Tue Jul 09 12:07:17 2013 +0000
@@ -16,6 +16,10 @@
     {
         this->_ref_inst=i_ref_inst;
     }
+    bool HttpdConnection::sendError(unsigned short i_status_code)
+    {
+        return NyLPC_TBool_TRUE==NyLPC_cHttpdConnection_sendResponseHeader2(this->_ref_inst,i_status_code,"text/html",0,NULL);
+    }
     bool HttpdConnection::sendHeader(unsigned short i_status_code,const char* i_content_type,const char* i_additional_header)
     {
         return NyLPC_TBool_TRUE==NyLPC_cHttpdConnection_sendResponseHeader(this->_ref_inst,i_status_code,i_content_type,i_additional_header);
--- a/mbed/HttpdConnection.h	Thu Jul 04 11:05:56 2013 +0000
+++ b/mbed/HttpdConnection.h	Tue Jul 09 12:07:17 2013 +0000
@@ -37,6 +37,11 @@
          */
         bool sendHeader(unsigned short i_status_code,const char* i_content_type,const char* i_additional_header,unsigned int i_length);
         /**
+         * This function send HTTP error response with empty body.
+         */
+        bool sendError(unsigned short i_status_code);
+        
+        /**
          * This function send formated text to response.
          * The function can be repeatedly called until the end of contents.
          */
--- a/mbed/ModBaseClass.cpp	Thu Jul 04 11:05:56 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +0,0 @@
-#pragma once
-
-#include "ModBaseClass.h"
-#include "HttpdConnection.h"
-#include "NyLPC_cHttpdConnection_protected.h"
-
-
-
-namespace MiMic
-{
-    ModBaseClass::ModBaseClass(const char* i_path)
-    {
-        this->_path=NULL;
-        this->setParam(i_path);
-    }
-    ModBaseClass::ModBaseClass()
-    {
-        this->_path=NULL;
-    }
-    ModBaseClass::~ModBaseClass()
-    {
-        if(this->_path!=NULL){
-            free(this->_path);
-        }
-    }
-    void ModBaseClass::setParam(const char* i_path)
-    {
-        if(this->_path!=NULL){
-            free(this->_path);            
-        }
-        this->_path=(char*)malloc(strlen(i_path)+1);
-        if(this->_path==NULL){
-            exit(-1);
-        }
-        strcpy(this->_path,i_path);
-    }
-    bool ModBaseClass::canHandle(HttpdConnection& i_connection)
-    {
-        if(this->_path==NULL){
-            return false;
-        }
-        //connectonの状態を確認
-        if(!NyLPC_cHttpdConnection_getReqStatus(i_connection._ref_inst)==NyLPC_cHttpdConnection_ReqStatus_REQPARSE)
-        {
-            return NyLPC_TBool_FALSE;
-        }        
-        const NyLPC_TChar* in_url;
-        in_url=NyLPC_cHttpdConnection_getUrlPrefix(i_connection._ref_inst);
-        size_t base_url_len=strlen(this->_path);
-        if(strlen(in_url)-2<base_url_len){
-            return false;
-        }
-        if(in_url[0]!='/' || strncmp(in_url+1,this->_path,base_url_len)!=0 || in_url[base_url_len+1]!='/'){
-            return false;
-        }
-        return true;
-    }        
-}
\ No newline at end of file
--- a/mbed/ModBaseClass.h	Thu Jul 04 11:05:56 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-#pragma once
-////////////////////////////////////////////////////////////////////////////////
-// ModBaseClass.h
-////////////////////////////////////////////////////////////////////////////////
-
-#include "NyLPC_net.h"
-
-
-namespace MiMic
-{
-    class HttpdConnection;
-
-    class ModBaseClass
-    {
-    protected:
-        char* _path;
-    public:
-        /**
-         * @param i_path
-         * target path
-         * <pre>
-         * ex.setParam("root")
-         * </pre>
-         */
-        ModBaseClass(const char* i_path);
-        ModBaseClass();
-        virtual ~ModBaseClass();
-    protected:
-        /**
-         * @param i_path
-         * target path
-         * <pre>
-         * ex.setParam("")
-         * </pre>
-         */
-        void setParam(const char* i_path);
-        bool canHandle(HttpdConnection& i_connection);
-    };
-}
\ No newline at end of file
--- a/mbed/ModFileIo.cpp	Thu Jul 04 11:05:56 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,128 +0,0 @@
-#include <ModFileIo.h>
-#include <stdio.h>
-#include "mbed.h"
-using namespace MiMic;
-/*
- * FileIO class
- */
-typedef struct TcModFileIoDumy
-{
-    NyLPC_TcModFileIoBaseClass_t super;
-}TcFileIoDumy_t;
-
-const static char* STR_TEXT_HTML="text/html";
-#define SIZE_OF_FBUF 256
-
-
-
-static NyLPC_TBool upload_handler(NyLPC_TcHttpdConnection_t* i_connection,const NyLPC_TChar* i_fname,NyLPC_TcHttpBodyParser_t* i_body_parser)
-{
-    char* buf=Httpd::_shared_buf;// This handler called with lock!
-
-    //save to new file
-    FILE *fp;
-    fp = fopen(i_fname, "w");
-    if(fp==NULL){
-        NyLPC_cHttpdConnection_sendResponseHeader2(i_connection,500,STR_TEXT_HTML,0,NULL);
-        return NyLPC_TBool_FALSE;
-    }
-    NyLPC_TInt16 l;
-    if(NyLPC_cHttpBodyParser_parseStream(i_body_parser,NyLPC_cHttpdConnection_refStream(i_connection),buf,SIZE_OF_FBUF,&l)){
-        while(l>0){
-            fwrite(buf,1,l,fp);            
-            if(!NyLPC_cHttpBodyParser_parseStream(i_body_parser,NyLPC_cHttpdConnection_refStream(i_connection),buf,SIZE_OF_FBUF,&l)){
-                NyLPC_OnErrorGoto(Error_FILE);
-            }
-        }
-    }
-    fclose(fp);    
-    //write response
-    NyLPC_cHttpdConnection_sendResponseHeader2(i_connection,200,STR_TEXT_HTML,0,NULL);
-    return NyLPC_TBool_TRUE;
-Error_FILE:
-    fclose(fp);
-    NyLPC_cHttpdConnection_sendResponseHeader2(i_connection,500,STR_TEXT_HTML,0,NULL);
-    return NyLPC_TBool_FALSE;
-}
-
-static NyLPC_TBool create_handler(NyLPC_TcHttpdConnection_t* i_connection,const NyLPC_TChar* i_fname)
-{
-    FILE *fp; 
-    fp = fopen(i_fname, "w");
-    if(fp!=NULL){
-        fclose(fp);
-        NyLPC_cHttpdConnection_sendResponseHeader2(i_connection,200,STR_TEXT_HTML,0,NULL);
-        return NyLPC_TBool_TRUE;
-    }
-    NyLPC_cHttpdConnection_sendResponseHeader2(i_connection,500,STR_TEXT_HTML,0,NULL);
-    return NyLPC_TBool_FALSE;
-}
-
-static NyLPC_TBool remove_handler(NyLPC_TcHttpdConnection_t* i_connection,const NyLPC_TChar* i_fname)
-{
-    if(remove(i_fname)==0){
-        NyLPC_cHttpdConnection_sendResponseHeader2(i_connection,200,STR_TEXT_HTML,0,NULL);
-        return NyLPC_TBool_TRUE;
-    }
-    //500ERROR
-    NyLPC_cHttpdConnection_sendResponseHeader2(i_connection,500,STR_TEXT_HTML,0,NULL);
-    return NyLPC_TBool_FALSE;
-}
-
-
-
-static void cModFileIoDumy_initialize(TcFileIoDumy_t* i_inst,const char* i_root_path)
-{
-    NyLPC_cModFileIoBaseClass_initialize(&(i_inst->super),i_root_path);
-    i_inst->super._abstruct_function.upload=upload_handler;
-    i_inst->super._abstruct_function.create=create_handler;
-    i_inst->super._abstruct_function.remove=remove_handler;
-}
-#define cModFileIoDumy_finalize(i_inst) NyLPC_cModFileIoBaseClass_finalize(&(i_inst)->super)
-#define cModFileIoDumy_canHandle(i_inst,i_connection) NyLPC_cModFileIoBaseClass_canHandle(&(i_inst)->super,i_connection)
-#define cModFileIoDumy_execute(i_inst,i_connection) NyLPC_cModFileIoBaseClass_execute(&(i_inst)->super,i_connection)
-
-
-
-
-
-   
-   
-namespace MiMic
-{  
-   
-   
-    ModFileIo::ModFileIo(const char* i_path):ModBaseClass(i_path)
-    {
-    }
-    ModFileIo::ModFileIo()
-    {
-    }
-    ModFileIo::~ModFileIo()
-    {
-    }
-    void ModFileIo::setParam(const char* i_path)
-    {
-        ModBaseClass::setParam(i_path);
-    }
-    bool ModFileIo::execute(HttpdConnection& i_connection)
-    {
-        //check parametor
-        if(this->_path==NULL){
-            return false;
-        }
-        TcModFileIoDumy mod;
-        cModFileIoDumy_initialize(&mod,this->_path);
-        if(cModFileIoDumy_canHandle(&mod,i_connection._ref_inst)){
-            cModFileIoDumy_execute(&mod,i_connection._ref_inst);
-            cModFileIoDumy_finalize(&mod);
-            return true;
-        }
-        cModFileIoDumy_finalize(&mod);
-        return false;
-    }   
-   
-   
-    
-
-}
\ No newline at end of file
--- a/mbed/ModFileIo.h	Thu Jul 04 11:05:56 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-#include "NyLPC_net.h"
-#include "ModBaseClass.h"
-#include "HttpdConnection.h"
-#include "Httpd.h"
-
-namespace MiMic
-{
-    class HttpdConnection;
-
-    /**
-     * This class is httpd module.
-     * The class provides 3 services.
-     * <ul>
-     * <li>create a blank file.</li>
-     * <li>remove a file.</li>
-     * <li>update a file.</li>
-     * </ul>
-     */
-    class ModFileIo:ModBaseClass
-    {
-    public:
-
-        ModFileIo(const char* i_path);
-        ModFileIo();
-        virtual ~ModFileIo();
-        void setParam(const char* i_path);
-        bool execute(HttpdConnection& i_connection);
-    };
-}
\ No newline at end of file
--- a/mbed/ModLocalFileSystem.cpp	Thu Jul 04 11:05:56 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,236 +0,0 @@
-#include "ModLocalFileSystem.h"
-#include "HttpdConnection.h"
-#include "UrlReader.h"
-#include "Http.h"
-#include "Httpd.h"
-#include "NyLPC_net.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <typeinfo>
-#include "mbed.h"
-#include "FATDirHandle.h"
-
-
-using namespace MiMic;
-static void retDirJson(UrlReader& url,char* buf,HttpdConnection& i_connection)
-{
-   //assert(HEAD or GET)
-   //directory-list json
-    if(!NyLPC_cHttpdUtils_sendJsonHeader((i_connection._ref_inst))){
-        return;
-    }
-    if(!i_connection.isMethodType(Http::MT_GET)){
-        return;
-    }
-    const char* t;
-    int l;
-    url.getPath(t,l);
-    buf[l]='\0';//split path
-    //remove '/'
-    if(buf[l-1]=='/'){
-        buf[l-1]='\0';
-    }        
-    DIR* d=opendir(buf);
-    if ( d == NULL )
-    {
-        i_connection.sendBodyF("{\"dir\":\"%s\",\"status\":404,\"list\":[]}",buf);
-        return;
-    }
-    if(!i_connection.isMethodType(Http::MT_GET)){
-        //nothing to do
-    }else{
-        bool is_fatfs=(typeid(*d) == typeid(FATDirHandle));
-        struct dirent *p;
-        p = readdir(d);
-        i_connection.sendBodyF("{\"dir\":\"%s\",\"status\":200,\"list\":[",buf);
-        for(;;)
-        {
-            if(is_fatfs){
-                bool isdir=(((struct direntFAT*)(p))->fattrib & AM_DIR)!=0;
-                i_connection.sendBodyF("{\"name\":\"%s\",\"mtype\":\"%s\",\"size\":%u}",
-                p->d_name,isdir?"directory":NyLPC_cMiMeType_getFileName2MimeType(p->d_name),
-                isdir?0:((struct direntFAT*)(p))->fsize);
-            }else{
-                i_connection.sendBodyF("{\"name\":\"%s\",\"mtype\":\"%s\",\"size\":undefined}",
-                p->d_name,NyLPC_cMiMeType_getFileName2MimeType(p->d_name));
-            }
-            p = readdir(d);
-            if(p==NULL){
-                break;
-            }
-            i_connection.sendBodyF(",");                        
-        }
-        i_connection.sendBodyF("]}");
-    }
-    closedir(d);
-}
-static void retDirHtml(UrlReader& url,char* buf,HttpdConnection& i_connection)
-{
-    //assert(HEAD or GET)
-    buf[strlen(buf)-1]='\0';//convert to dir path
-    DIR* d=opendir(buf);
-    if(d==NULL){
-        i_connection.sendHeader(403,"text/html",NULL);
-        if(!i_connection.isMethodType(Http::MT_GET)){
-            return;
-        }
-        i_connection.sendBodyF("<!DOCTYPE html><html><body><h1>403 Forbidden</h1><hr/>'%s'</body></html>",buf);
-        return;
-    }        
-    if(!i_connection.sendHeader(200,"text/html",NULL)){
-        //nothing to do
-    }else{
-        if(!i_connection.isMethodType(Http::MT_GET)){
-            //nothing to do.
-        }else{
-            bool is_fatfs=(typeid(*d) == typeid(FATDirHandle));
-            struct dirent *p;
-            p = readdir(d);
-            i_connection.sendBodyF(
-                "<!DOCTYPE html><html><body><h1>Index of %s</h1><hr/>\n"
-                "<ul>\n"
-                ,buf);
-            for(;;)
-            {
-                if(is_fatfs){
-                    if((((struct direntFAT*)(p))->fattrib & AM_DIR)!=0){
-                        //dir
-                        i_connection.sendBodyF("<li><a href=\"./%s/\">[DIR]%s</a></li>\n",p->d_name,p->d_name);
-                    }else{
-                        //file
-                        i_connection.sendBodyF("<li><a href=\"./%s\">%s</a></li>\n",p->d_name,p->d_name);
-                    }
-                }else{
-                    i_connection.sendBodyF("<li><a href=\"./%s\">%s</a></li>\n",
-                    p->d_name,p->d_name);
-                }
-                p = readdir(d);
-                if(p==NULL){
-                    break;
-                }
-            }
-            i_connection.sendBodyF("</ul></body></html>",buf);
-        }
-    }
-    closedir(d);
-}
-static void retFile(UrlReader& url,char* buf,HttpdConnection& i_connection)
-{
-    //file contents
-    {//split URL path and query
-        const char* t;
-        int l;
-        url.getPath(t,l);
-        buf[l]='\0';
-    }
-    //return content
-    FILE *fp;
-    size_t sz;
-    //size
-    fp = fopen(buf, "r"); 
-    if(fp==NULL){
-        i_connection.sendHeader(404,"text/html",NULL);
-        if(!i_connection.isMethodType(Http::MT_GET)){
-            return;
-        }
-        i_connection.sendBodyF("<!DOCTYPE html><html><body>'%s' not found.</body></html>",buf);
-        return;
-    }
-    
-    fseek(fp, 0, SEEK_END); // seek to end of file
-    sz = ftell(fp);       // get current file pointer
-    fseek(fp, 0, SEEK_SET); // seek back to beginning of file
-    if(i_connection.sendHeader(200,NyLPC_cMiMeType_getFileName2MimeType(buf),NULL,sz)){
-        if(!i_connection.isMethodType(Http::MT_GET)){
-            //nothing to do
-        }else{
-            Timer t;
-            t.start();
-            for(;;){
-                sz=fread(buf,1,Httpd::SIZE_OF_HTTP_BUF,fp);
-                if(sz<1){
-                    break;
-                }
-                if(!i_connection.sendBody(buf,sz)){
-                    break;
-                }
-                if(t.read_ms()>500){
-                    //switch transport thread
-                    i_connection.unlockHttpd();
-                    NyLPC_cThread_sleep(50);
-                    i_connection.lockHttpd();
-                    t.reset();
-                }
-            }
-        }
-    }
-    fclose(fp);
-}    
-
-
-namespace MiMic
-{
-    ModLocalFileSystem::ModLocalFileSystem(const char* i_path):ModBaseClass(i_path)
-    {
-    }
-    ModLocalFileSystem::ModLocalFileSystem():ModBaseClass()
-    {
-    }
-    ModLocalFileSystem::~ModLocalFileSystem()
-    {
-    }
-    void ModLocalFileSystem::setParam(const char* i_path)
-    {
-        ModBaseClass::setParam(i_path);
-    }
-  
-    bool ModLocalFileSystem::execute(HttpdConnection& i_connection)
-    {
-        //check platform
-        //<write here! />
-        
-        //check prefix
-        if(!this->canHandle(i_connection)){
-            return false;
-        }
-        //check Method type
-        {
-            int mt=i_connection.getMethodType();
-            if(mt!=Http::MT_GET && mt!=Http::MT_HEAD){
-                //method not allowed.
-                i_connection.sendHeader(405,"text/html",NULL);
-                return true;
-            }
-        }
-        //Httpd lock
-        i_connection.lockHttpd();
-        char* buf=Httpd::_shared_buf;
-        
-        //set file path
-        {
-            //call ModUrl
-            NyLPC_TcModUrl_t mod;
-            NyLPC_cModUrl_initialize(&mod);
-            if(!NyLPC_cModUrl_execute2(&mod,i_connection._ref_inst,buf,Httpd::SIZE_OF_HTTP_BUF,0,NyLPC_cModUrl_ParseMode_ALL)){
-                NyLPC_cModUrl_finalize(&mod);
-                i_connection.unlockHttpd();
-                return true;
-            }
-            NyLPC_cModUrl_finalize(&mod);
-        }
-        UrlReader url(buf);
-        if(url.hasQueryKey("list")){
-            // if path has '/?list' query key,return directory information
-            retDirJson(url,buf,i_connection);
-        }else if(strchr(buf,'?')==NULL && strchr(buf,'#')==NULL && buf[strlen(buf)-1]=='/'){
-            //return directory html when URL has not bookmark and URL query and terminated by '/'.
-            retDirHtml(url,buf,i_connection);
-        }else{
-            retFile(url,buf,i_connection);
-        }
-        //Httpd unlock
-        i_connection.unlockHttpd();
-        return true;
-        
-    }
-}
--- a/mbed/ModLocalFileSystem.h	Thu Jul 04 11:05:56 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-#pragma once
-////////////////////////////////////////////////////////////////////////////////
-// ModRomFiles.h
-////////////////////////////////////////////////////////////////////////////////
-
-#include "NyLPC_net.h"
-#include "ModBaseClass.h"
-
-
-namespace MiMic
-{
-    class HttpdConnection;
-
-    /**
-     * This class is httpd module.
-     * The class provide files on mbed LocalFile System.
-     * The class provide 2 services.
-     * <ul>
-     * <li>lfile content provider.</li>
-     * This is response of local file path. for example "/local/file.txt". full content of file.
-     * <li>file list provider</li>
-     * This is array of json response. for example, "/local/"
-     * [{name:"name",size:"size",type:"type"}]
-     * </ul>
-     */
-    class ModLocalFileSystem:ModBaseClass
-    {
-    public:
-
-        ModLocalFileSystem(const char* i_path);
-        ModLocalFileSystem();
-        virtual ~ModLocalFileSystem();
-        void setParam(const char* i_path);
-        bool execute(HttpdConnection& i_connection);
-    };
-
-}
\ No newline at end of file
--- a/mbed/ModMiMicSetting.cpp	Thu Jul 04 11:05:56 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-#include "ModMiMicSetting.h"
-#include "HttpdConnection.h"
-#include "NyLPC_net.h"
-
-namespace MiMic
-{
-    ModMiMicSetting::ModMiMicSetting(const char* i_path):ModBaseClass(i_path)
-    {
-    }
-    ModMiMicSetting::ModMiMicSetting():ModBaseClass()
-    {
-    }
-    ModMiMicSetting::~ModMiMicSetting()
-    {
-    }
-    void ModMiMicSetting::setParam(const char* i_path)
-    {
-        ModBaseClass::setParam(i_path);
-    }
-    bool ModMiMicSetting::execute(HttpdConnection& i_connection)
-    {
-        NyLPC_TcModMiMicSetting_t mod;
-
-        //check parametor
-        if(this->_path==NULL){
-            return false;
-        }
-        NyLPC_cModMiMicSetting_initialize(&mod,this->_path);
-        if(NyLPC_cModMiMicSetting_canHandle(&mod,i_connection._ref_inst)){
-            NyLPC_cModMiMicSetting_execute(&mod,i_connection._ref_inst);
-            NyLPC_cModMiMicSetting_finalize(&mod);
-            return true;
-        }
-        NyLPC_cModMiMicSetting_finalize(&mod);
-        return false;
-    }
-
-}
\ No newline at end of file
--- a/mbed/ModMiMicSetting.h	Thu Jul 04 11:05:56 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-#pragma once
-////////////////////////////////////////////////////////////////////////////////
-// ModMiMicSetting.h
-////////////////////////////////////////////////////////////////////////////////
-
-#include "NyLPC_net.h"
-#include "ModBaseClass.h"
-
-
-namespace MiMic
-{
-    class HttpdConnection;
-    /**
-     * This class is a module for Httpd.
-     * The class provides an REST-API to set and get the on-chip configuration MiMicHttpd.
-     * The class is wrapper of NyLPC_TcModMiMicSetting class.
-     */
-    class ModMiMicSetting :ModBaseClass
-    {
-    public:
-        /**
-         * Constructor with parameter initialization.
-         */
-        ModMiMicSetting(const char* i_path);
-        /**
-         * Default constructor.
-         * Must be call {@link setParam} function after constructed.
-         */
-        ModMiMicSetting();
-        virtual ~ModMiMicSetting();
-        void setParam(const char* i_path);
-        /**
-          * This function processes a request. 
-          * The function checks whether a connection has a target request.
-          * If necessary, it will transmit a response.
-          * @return
-          * TRUE if request was processed. otherwise FALSE.
-          */
-        bool execute(HttpdConnection& i_connection);
-    };
-
-}
\ No newline at end of file
--- a/mbed/ModRemoteMcu.cpp	Thu Jul 04 11:05:56 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-#include "ModRemoteMcu.h"
-#include "HttpdConnection.h"
-
-namespace MiMic
-{
-    ModRemoteMcu::ModRemoteMcu(const char* i_path):ModBaseClass(i_path)
-    {
-    }
-    ModRemoteMcu::ModRemoteMcu()
-    {
-    }
-    ModRemoteMcu::~ModRemoteMcu()
-    {
-    }
-    void ModRemoteMcu::setParam(const char* i_path)
-    {
-        ModBaseClass::setParam(i_path);
-    }
-    bool ModRemoteMcu::execute(HttpdConnection& i_connection)
-    {
-        NyLPC_TcModRemoteMcu_t mod;
-
-        //check parametor
-        if(this->_path==NULL){
-            return false;
-        }
-        NyLPC_cModRemoteMcu_initialize(&mod,this->_path);
-        if(NyLPC_cModRemoteMcu_canHandle(&mod,i_connection._ref_inst)){
-            NyLPC_cModRemoteMcu_execute(&mod,i_connection._ref_inst);
-            NyLPC_cModRemoteMcu_finalize(&mod);
-            return true;
-        }
-        NyLPC_cModRemoteMcu_finalize(&mod);
-        return false;
-    }
-
-}
\ No newline at end of file
--- a/mbed/ModRemoteMcu.h	Thu Jul 04 11:05:56 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-#pragma once
-////////////////////////////////////////////////////////////////////////////////
-// ModRemoteMcu.h
-////////////////////////////////////////////////////////////////////////////////
-
-#include "NyLPC_net.h"
-#include "ModBaseClass.h"
-
-
-namespace MiMic
-{
-    class HttpdConnection;
-    /**
-     * This class is a module for Httpd.
-     * The class provides an REST-API to execute MiMic ByteCode.
-     * The class is wrapper of NyLPC_TcModRemoteMcu class.
-     */
-    class ModRemoteMcu:ModBaseClass
-    {
-    public:
-        /**
-         * Constructor with parameter initialization.
-         */
-        ModRemoteMcu(const char* i_path);
-        /**
-         * Default constructor.
-         * Must be call {@link setParam} function after constructed.
-         */
-        ModRemoteMcu();
-        virtual ~ModRemoteMcu();
-        void setParam(const char* i_path);
-        /**
-          * This function processes a request. 
-          * The function checks whether a connection has a target request.
-          * If necessary, it will transmit a response.
-          * @return
-          * TRUE if request was processed. otherwise FALSE.
-          */
-        bool execute(HttpdConnection& i_connection);
-    };
-
-}
\ No newline at end of file
--- a/mbed/ModRomFiles.cpp	Thu Jul 04 11:05:56 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-#include "ModRomFiles.h"
-#include "HttpdConnection.h"
-
-namespace MiMic
-{
-    ModRomFiles::ModRomFiles(const char* i_path,const NyLPC_TRomFileData* i_ref_fsdata,unsigned short i_num):ModBaseClass(i_path)
-    {
-    }
-    ModRomFiles::ModRomFiles():ModBaseClass()
-    {
-    }
-    ModRomFiles::~ModRomFiles()
-    {
-    }
-    void ModRomFiles::setParam(const char* i_path,const NyLPC_TRomFileData* i_ref_fsdata,unsigned short i_num)
-    {
-        ModBaseClass::setParam(i_path);
-        this->_ref_fsdata=i_ref_fsdata;
-        this->_num=i_num;
-    }
-    bool ModRomFiles::execute(HttpdConnection& i_connection)
-    {
-        NyLPC_TcModRomFiles_t mod;
-
-        //check parametor
-        if(this->_path==NULL){
-            return false;
-        }
-        NyLPC_cModRomFiles_initialize(&mod,this->_path,this->_ref_fsdata,this->_num);
-        if(NyLPC_cModRomFiles_canHandle(&mod,i_connection._ref_inst)){
-            NyLPC_cModRomFiles_execute(&mod,i_connection._ref_inst);
-            NyLPC_cModRomFiles_finalize(&mod);
-            return true;
-        }
-        NyLPC_cModRomFiles_finalize(&mod);
-        return false;
-    }
-
-}
\ No newline at end of file
--- a/mbed/ModRomFiles.h	Thu Jul 04 11:05:56 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-#pragma once
-////////////////////////////////////////////////////////////////////////////////
-// ModRomFiles.h
-////////////////////////////////////////////////////////////////////////////////
-
-#include "NyLPC_net.h"
-#include "ModBaseClass.h"
-
-
-namespace MiMic
-{
-    class HttpdConnection;
-    /**
-     * This class is a module for Httpd.
-     * The class sends file image which is stored on ROM.
-     * The class is wrapper of NyLPC_tcModRomFiles class.
-     */
-    class ModRomFiles:ModBaseClass
-    {
-    private:
-        const NyLPC_TRomFileData* _ref_fsdata;
-        unsigned short _num;
-    public:
-        /**
-         * Constructor with parameter initialization.
-         */
-        ModRomFiles(const char* i_path,const NyLPC_TRomFileData* i_ref_fsdata,unsigned short i_num);
-        /**
-         * Default constructor.
-         * Must be call {@link setParam} function after constructed.
-         */
-        ModRomFiles();
-        virtual ~ModRomFiles();
-        /**
-         * @param i_path
-         * target path
-         * <pre>
-         * ex.setParam("setup")
-         * </pre>
-         */
-        void setParam(const char* i_path,const NyLPC_TRomFileData* i_ref_fsdata,unsigned short i_num);
-        /**
-          * This function processes a request. 
-          * The function checks whether a connection has a target request.
-          * If necessary, it will transmit a response.
-          * @return
-          * TRUE if request was processed. otherwise FALSE.
-          */
-        bool execute(HttpdConnection& i_connection);
-    };
-
-}
\ No newline at end of file
--- a/mbed/ModUrl.cpp	Thu Jul 04 11:05:56 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-#include "ModUrl.h"
-#include "HttpdConnection.h"
-
-namespace MiMic
-{
-    ModUrl::ModUrl()
-    {
-    }
-    ModUrl::~ModUrl()
-    {
-    }
-    bool ModUrl::execute(HttpdConnection& i_connection,char* o_url_buf,int i_buf_len,int* o_method_type)
-    {
-        NyLPC_TcModUrl_t mod;
-        if(i_buf_len<1){
-            return false;
-        }
-        NyLPC_cModUrl_initialize(&mod);
-        if(!NyLPC_cModUrl_execute(&mod,i_connection._ref_inst,o_url_buf,i_buf_len)){
-            *o_url_buf='\0';
-        }
-        if(o_method_type!=NULL){
-            *o_method_type=NyLPC_cModUrl_getMethod(&mod);
-        }
-        NyLPC_cModUrl_finalize(&mod);
-        return true;
-    }
-
-}
\ No newline at end of file
--- a/mbed/ModUrl.h	Thu Jul 04 11:05:56 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-#pragma once
-////////////////////////////////////////////////////////////////////////////////
-// ModRomFiles.h
-////////////////////////////////////////////////////////////////////////////////
-
-#include "NyLPC_net.h"
-
-
-namespace MiMic
-{
-    class HttpdConnection;
-    /**
-     * This class is a module for Httpd.
-     * The class parses a request path to buffer from connection.
-     */
-    class ModUrl
-    {
-    private:
-        int _method_type;
-    public:
-        const static int METHOD_GET =NyLPC_THttpMethodType_GET;
-        const static int METHOD_HEAD=NyLPC_THttpMethodType_HEAD;
-        const static int METHOD_POST=NyLPC_THttpMethodType_POST;
-    public:
-        /**
-         * Constructor.
-         */
-        ModUrl();
-        virtual ~ModUrl();
-
-        /**
-          * This function processes a request.
-          * @param i_connection
-          * @param o_url_buf
-          * Output parametor.
-          * Address of buffer which accept URL string.
-          * The string will be "" (zero text) if URL too long or parsing failed. 
-          * @param i_buf_len
-          * Size of o_url buffer in byte.
-          * @param o_method_type
-          * Address of variable which accept HTTP-Method type.
-          * Can be omitted.
-          * @return
-          * TRUE if request was processed. otherwise FALSE.
-          * The value describes processing status. It is not parsing error status.
-          */
-        bool execute(HttpdConnection& i_connection,char* o_url_buf,int i_buf_len,int* o_method_type=NULL);
-    };
-
-}
\ No newline at end of file
--- a/mbed/mimic.h	Thu Jul 04 11:05:56 2013 +0000
+++ b/mbed/mimic.h	Tue Jul 09 12:07:17 2013 +0000
@@ -8,12 +8,12 @@
 #include "Http.h"
 #include "UrlReader.h"
 #include "HttpdConnection.h"
-#include "ModUrl.h"
-#include "ModRomFiles.h"
-#include "ModRemoteMcu.h"
-#include "ModMiMicSetting.h"
-#include "ModLocalFileSystem.h"
-#include "ModFileIo.h"
+#include "mod/ModUrl.h"
+#include "mod/ModRomFiles.h"
+#include "mod/ModRemoteMcu.h"
+#include "mod/ModMiMicSetting.h"
+#include "mod/ModLocalFileSystem.h"
+#include "mod/ModFileIo.h"
 #include "LocalFileSystem2.h"
 
 using namespace MiMic;
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/mod/ModBaseClass.cpp	Tue Jul 09 12:07:17 2013 +0000
@@ -0,0 +1,58 @@
+#pragma once
+
+#include "ModBaseClass.h"
+#include "HttpdConnection.h"
+#include "NyLPC_cHttpdConnection_protected.h"
+
+
+
+namespace MiMic
+{
+    ModBaseClass::ModBaseClass(const char* i_path)
+    {
+        this->_path=NULL;
+        this->setParam(i_path);
+    }
+    ModBaseClass::ModBaseClass()
+    {
+        this->_path=NULL;
+    }
+    ModBaseClass::~ModBaseClass()
+    {
+        if(this->_path!=NULL){
+            free(this->_path);
+        }
+    }
+    void ModBaseClass::setParam(const char* i_path)
+    {
+        if(this->_path!=NULL){
+            free(this->_path);            
+        }
+        this->_path=(char*)malloc(strlen(i_path)+1);
+        if(this->_path==NULL){
+            exit(-1);
+        }
+        strcpy(this->_path,i_path);
+    }
+    bool ModBaseClass::canHandle(HttpdConnection& i_connection)
+    {
+        if(this->_path==NULL){
+            return false;
+        }
+        //connectonの状態を確認
+        if(!NyLPC_cHttpdConnection_getReqStatus(i_connection._ref_inst)==NyLPC_cHttpdConnection_ReqStatus_REQPARSE)
+        {
+            return NyLPC_TBool_FALSE;
+        }        
+        const NyLPC_TChar* in_url;
+        in_url=NyLPC_cHttpdConnection_getUrlPrefix(i_connection._ref_inst);
+        size_t base_url_len=strlen(this->_path);
+        if(strlen(in_url)-2<base_url_len){
+            return false;
+        }
+        if(in_url[0]!='/' || strncmp(in_url+1,this->_path,base_url_len)!=0 || in_url[base_url_len+1]!='/'){
+            return false;
+        }
+        return true;
+    }        
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/mod/ModBaseClass.h	Tue Jul 09 12:07:17 2013 +0000
@@ -0,0 +1,39 @@
+#pragma once
+////////////////////////////////////////////////////////////////////////////////
+// ModBaseClass.h
+////////////////////////////////////////////////////////////////////////////////
+
+#include "NyLPC_net.h"
+
+
+namespace MiMic
+{
+    class HttpdConnection;
+
+    class ModBaseClass
+    {
+    protected:
+        char* _path;
+    public:
+        /**
+         * @param i_path
+         * target path
+         * <pre>
+         * ex.setParam("root")
+         * </pre>
+         */
+        ModBaseClass(const char* i_path);
+        ModBaseClass();
+        virtual ~ModBaseClass();
+    protected:
+        /**
+         * @param i_path
+         * target path
+         * <pre>
+         * ex.setParam("")
+         * </pre>
+         */
+        void setParam(const char* i_path);
+        bool canHandle(HttpdConnection& i_connection);
+    };
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/mod/ModFileIo.cpp	Tue Jul 09 12:07:17 2013 +0000
@@ -0,0 +1,128 @@
+#include <ModFileIo.h>
+#include <stdio.h>
+#include "mbed.h"
+using namespace MiMic;
+/*
+ * FileIO class
+ */
+typedef struct TcModFileIoDumy
+{
+    NyLPC_TcModFileIoBaseClass_t super;
+}TcFileIoDumy_t;
+
+const static char* STR_TEXT_HTML="text/html";
+#define SIZE_OF_FBUF 256
+
+
+
+static NyLPC_TBool upload_handler(NyLPC_TcHttpdConnection_t* i_connection,const NyLPC_TChar* i_fname,NyLPC_TcHttpBodyParser_t* i_body_parser)
+{
+    char* buf=Httpd::_shared_buf;// This handler called with lock!
+
+    //save to new file
+    FILE *fp;
+    fp = fopen(i_fname, "w");
+    if(fp==NULL){
+        NyLPC_cHttpdUtils_sendErrorResponse(i_connection,500);
+        return NyLPC_TBool_FALSE;
+    }
+    NyLPC_TInt16 l;
+    if(NyLPC_cHttpBodyParser_parseStream(i_body_parser,NyLPC_cHttpdConnection_refStream(i_connection),buf,SIZE_OF_FBUF,&l)){
+        while(l>0){
+            fwrite(buf,1,l,fp);            
+            if(!NyLPC_cHttpBodyParser_parseStream(i_body_parser,NyLPC_cHttpdConnection_refStream(i_connection),buf,SIZE_OF_FBUF,&l)){
+                NyLPC_OnErrorGoto(Error_FILE);
+            }
+        }
+    }
+    fclose(fp);    
+    //write response
+    NyLPC_cHttpdConnection_sendResponseHeader2(i_connection,200,STR_TEXT_HTML,0,NULL);
+    return NyLPC_TBool_TRUE;
+Error_FILE:
+    fclose(fp);
+    NyLPC_cHttpdUtils_sendErrorResponse(i_connection,500);
+    return NyLPC_TBool_FALSE;
+}
+
+static NyLPC_TBool create_handler(NyLPC_TcHttpdConnection_t* i_connection,const NyLPC_TChar* i_fname)
+{
+    FILE *fp; 
+    fp = fopen(i_fname, "w");
+    if(fp!=NULL){
+        fclose(fp);
+        NyLPC_cHttpdConnection_sendResponseHeader2(i_connection,200,STR_TEXT_HTML,0,NULL);
+        return NyLPC_TBool_TRUE;
+    }
+    NyLPC_cHttpdUtils_sendErrorResponse(i_connection,500);
+    return NyLPC_TBool_FALSE;
+}
+
+static NyLPC_TBool remove_handler(NyLPC_TcHttpdConnection_t* i_connection,const NyLPC_TChar* i_fname)
+{
+    if(remove(i_fname)==0){
+        NyLPC_cHttpdConnection_sendResponseHeader2(i_connection,200,STR_TEXT_HTML,0,NULL);
+        return NyLPC_TBool_TRUE;
+    }
+    //500ERROR
+    NyLPC_cHttpdUtils_sendErrorResponse(i_connection,500);
+    return NyLPC_TBool_FALSE;
+}
+
+
+
+static void cModFileIoDumy_initialize(TcFileIoDumy_t* i_inst,const char* i_root_path)
+{
+    NyLPC_cModFileIoBaseClass_initialize(&(i_inst->super),i_root_path);
+    i_inst->super._abstruct_function.upload=upload_handler;
+    i_inst->super._abstruct_function.create=create_handler;
+    i_inst->super._abstruct_function.remove=remove_handler;
+}
+#define cModFileIoDumy_finalize(i_inst) NyLPC_cModFileIoBaseClass_finalize(&(i_inst)->super)
+#define cModFileIoDumy_canHandle(i_inst,i_connection) NyLPC_cModFileIoBaseClass_canHandle(&(i_inst)->super,i_connection)
+#define cModFileIoDumy_execute(i_inst,i_connection) NyLPC_cModFileIoBaseClass_execute(&(i_inst)->super,i_connection)
+
+
+
+
+
+   
+   
+namespace MiMic
+{  
+   
+   
+    ModFileIo::ModFileIo(const char* i_path):ModBaseClass(i_path)
+    {
+    }
+    ModFileIo::ModFileIo()
+    {
+    }
+    ModFileIo::~ModFileIo()
+    {
+    }
+    void ModFileIo::setParam(const char* i_path)
+    {
+        ModBaseClass::setParam(i_path);
+    }
+    bool ModFileIo::execute(HttpdConnection& i_connection)
+    {
+        //check parametor
+        if(this->_path==NULL){
+            return false;
+        }
+        TcModFileIoDumy mod;
+        cModFileIoDumy_initialize(&mod,this->_path);
+        if(cModFileIoDumy_canHandle(&mod,i_connection._ref_inst)){
+            cModFileIoDumy_execute(&mod,i_connection._ref_inst);
+            cModFileIoDumy_finalize(&mod);
+            return true;
+        }
+        cModFileIoDumy_finalize(&mod);
+        return false;
+    }   
+   
+   
+    
+
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/mod/ModFileIo.h	Tue Jul 09 12:07:17 2013 +0000
@@ -0,0 +1,29 @@
+#include "NyLPC_net.h"
+#include "ModBaseClass.h"
+#include "HttpdConnection.h"
+#include "Httpd.h"
+
+namespace MiMic
+{
+    class HttpdConnection;
+
+    /**
+     * This class is httpd module.
+     * The class provides 3 services.
+     * <ul>
+     * <li>create a blank file.</li>
+     * <li>remove a file.</li>
+     * <li>update a file.</li>
+     * </ul>
+     */
+    class ModFileIo:ModBaseClass
+    {
+    public:
+
+        ModFileIo(const char* i_path);
+        ModFileIo();
+        virtual ~ModFileIo();
+        void setParam(const char* i_path);
+        bool execute(HttpdConnection& i_connection);
+    };
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/mod/ModLocalFileSystem.cpp	Tue Jul 09 12:07:17 2013 +0000
@@ -0,0 +1,238 @@
+#include "ModLocalFileSystem.h"
+#include "HttpdConnection.h"
+#include "UrlReader.h"
+#include "Http.h"
+#include "Httpd.h"
+#include "NyLPC_net.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <typeinfo>
+#include "mbed.h"
+#include "FATDirHandle.h"
+
+
+using namespace MiMic;
+static void retDirJson(UrlReader& url,char* buf,HttpdConnection& i_connection)
+{
+   //assert(HEAD or GET)
+   //directory-list json
+    if(!NyLPC_cHttpdUtils_sendJsonHeader((i_connection._ref_inst))){
+        return;
+    }
+    if(!i_connection.isMethodType(Http::MT_GET)){
+        return;
+    }
+    const char* t;
+    int l;
+    url.getPath(t,l);
+    buf[l]='\0';//split path
+    //remove '/'
+    if(buf[l-1]=='/'){
+        buf[l-1]='\0';
+    }        
+    DIR* d=opendir(buf);
+    if ( d == NULL )
+    {
+        i_connection.sendBodyF("{\"dir\":\"%s\",\"status\":404,\"list\":[]}",buf);
+        return;
+    }
+    if(!i_connection.isMethodType(Http::MT_GET)){
+        //nothing to do
+    }else{
+        bool is_fatfs=(typeid(*d) == typeid(FATDirHandle));
+        struct dirent *p;
+        p = readdir(d);
+        i_connection.sendBodyF("{\"dir\":\"%s\",\"status\":200,\"list\":[",buf);
+        for(;;)
+        {
+            if(is_fatfs){
+                bool isdir=(((struct direntFAT*)(p))->fattrib & AM_DIR)!=0;
+                i_connection.sendBodyF("{\"name\":\"%s\",\"mtype\":\"%s\",\"size\":%u}",
+                p->d_name,isdir?"directory":NyLPC_cMiMeType_getFileName2MimeType(p->d_name),
+                isdir?0:((struct direntFAT*)(p))->fsize);
+            }else{
+                i_connection.sendBodyF("{\"name\":\"%s\",\"mtype\":\"%s\",\"size\":undefined}",
+                p->d_name,NyLPC_cMiMeType_getFileName2MimeType(p->d_name));
+            }
+            p = readdir(d);
+            if(p==NULL){
+                break;
+            }
+            i_connection.sendBodyF(",");                        
+        }
+        i_connection.sendBodyF("]}");
+    }
+    closedir(d);
+}
+static void retDirHtml(UrlReader& url,char* buf,HttpdConnection& i_connection)
+{
+    //assert(HEAD or GET)
+    buf[strlen(buf)-1]='\0';//convert to dir path
+    DIR* d=opendir(buf);
+    if(d==NULL){
+        i_connection.sendError(403);
+        if(!i_connection.isMethodType(Http::MT_GET)){
+            return;
+        }
+        i_connection.sendBodyF("<!DOCTYPE html><html><body><h1>403 Forbidden</h1><hr/>'%s'</body></html>",buf);
+        return;
+    }        
+    if(!i_connection.sendHeader(200,"text/html",NULL)){
+        //nothing to do
+    }else{
+        if(!i_connection.isMethodType(Http::MT_GET)){
+            //nothing to do.
+        }else{
+            bool is_fatfs=(typeid(*d) == typeid(FATDirHandle));
+            struct dirent *p;
+            p = readdir(d);
+            i_connection.sendBodyF(
+                "<!DOCTYPE html><html><body><h1>Index of %s</h1><hr/>\n"
+                "<ul>\n"
+                ,buf);
+            for(;;)
+            {
+                if(is_fatfs){
+                    if((((struct direntFAT*)(p))->fattrib & AM_DIR)!=0){
+                        //dir
+                        i_connection.sendBodyF("<li><a href=\"./%s/\">[DIR]%s</a></li>\n",p->d_name,p->d_name);
+                    }else{
+                        //file
+                        i_connection.sendBodyF("<li><a href=\"./%s\">%s</a></li>\n",p->d_name,p->d_name);
+                    }
+                }else{
+                    i_connection.sendBodyF("<li><a href=\"./%s\">%s</a></li>\n",
+                    p->d_name,p->d_name);
+                }
+                p = readdir(d);
+                if(p==NULL){
+                    break;
+                }
+            }
+            i_connection.sendBodyF("</ul></body></html>",buf);
+        }
+    }
+    closedir(d);
+}
+static void retFile(UrlReader& url,char* buf,HttpdConnection& i_connection)
+{
+    //file contents
+    {//split URL path and query
+        const char* t;
+        int l;
+        url.getPath(t,l);
+        buf[l]='\0';
+    }
+    //return content
+    FILE *fp;
+    size_t sz;
+    //size
+    fp = fopen(buf, "r"); 
+    if(fp==NULL){
+        i_connection.sendError(404);
+        if(!i_connection.isMethodType(Http::MT_GET)){
+            return;
+        }
+        i_connection.sendBodyF("<!DOCTYPE html><html><body>'%s' not found.</body></html>",buf);
+        return;
+    }
+    
+    fseek(fp, 0, SEEK_END); // seek to end of file
+    sz = ftell(fp);       // get current file pointer
+    fseek(fp, 0, SEEK_SET); // seek back to beginning of file
+    if(i_connection.sendHeader(200,NyLPC_cMiMeType_getFileName2MimeType(buf),NULL,sz)){
+        if(!i_connection.isMethodType(Http::MT_GET)){
+            //nothing to do
+        }else{
+            Timer t;
+            t.start();
+            for(;;){
+                sz=fread(buf,1,Httpd::SIZE_OF_HTTP_BUF,fp);
+                if(sz<1){
+                    break;
+                }
+                if(!i_connection.sendBody(buf,sz)){
+                    break;
+                }
+                //switch other session
+                if(t.read_ms()>500){
+                    //switch transport thread
+                    i_connection.unlockHttpd();
+                    NyLPC_cThread_sleep(50);
+                    i_connection.lockHttpd();
+                    t.reset();
+                }
+            }
+        }
+    }
+    fclose(fp);
+}    
+
+
+namespace MiMic
+{
+    ModLocalFileSystem::ModLocalFileSystem(const char* i_path):ModBaseClass(i_path)
+    {
+    }
+    ModLocalFileSystem::ModLocalFileSystem():ModBaseClass()
+    {
+    }
+    ModLocalFileSystem::~ModLocalFileSystem()
+    {
+    }
+    void ModLocalFileSystem::setParam(const char* i_path)
+    {
+        ModBaseClass::setParam(i_path);
+    }
+  
+    bool ModLocalFileSystem::execute(HttpdConnection& i_connection)
+    {
+        //check platform
+        //<write here! />
+        
+        //check prefix
+        if(!this->canHandle(i_connection)){
+            return false;
+        }
+        
+        //check Method type
+        {
+            int mt=i_connection.getMethodType();
+            if(mt!=Http::MT_GET && mt!=Http::MT_HEAD){
+                //method not allowed.
+                i_connection.sendError(405);
+                return true;
+            }
+        }
+        //Httpd lock
+        i_connection.lockHttpd();
+        char* buf=Httpd::_shared_buf;
+        
+        //set file path
+        {
+            //call ModUrl
+            NyLPC_TcModUrl_t mod;
+            NyLPC_cModUrl_initialize(&mod);
+            if(!NyLPC_cModUrl_execute2(&mod,i_connection._ref_inst,buf,Httpd::SIZE_OF_HTTP_BUF,0,NyLPC_cModUrl_ParseMode_ALL)){
+                NyLPC_cModUrl_finalize(&mod);
+                i_connection.unlockHttpd();
+                return true;
+            }
+            NyLPC_cModUrl_finalize(&mod);
+        }
+        UrlReader url(buf);
+        if(url.hasQueryKey("list")){
+            // if path has '/?list' query key,return directory information
+            retDirJson(url,buf,i_connection);
+        }else if(strchr(buf,'?')==NULL && strchr(buf,'#')==NULL && buf[strlen(buf)-1]=='/'){
+            //return directory html when URL has not bookmark and URL query and terminated by '/'.
+            retDirHtml(url,buf,i_connection);
+        }else{
+            retFile(url,buf,i_connection);
+        }
+        //Httpd unlock
+        i_connection.unlockHttpd();
+        return true;
+        
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/mod/ModLocalFileSystem.h	Tue Jul 09 12:07:17 2013 +0000
@@ -0,0 +1,37 @@
+#pragma once
+////////////////////////////////////////////////////////////////////////////////
+// ModRomFiles.h
+////////////////////////////////////////////////////////////////////////////////
+
+#include "NyLPC_net.h"
+#include "ModBaseClass.h"
+
+
+namespace MiMic
+{
+    class HttpdConnection;
+
+    /**
+     * This class is httpd module.
+     * The class provide files on mbed LocalFile System.
+     * The class provide 2 services.
+     * <ul>
+     * <li>lfile content provider.</li>
+     * This is response of local file path. for example "/local/file.txt". full content of file.
+     * <li>file list provider</li>
+     * This is array of json response. for example, "/local/"
+     * [{name:"name",size:"size",type:"type"}]
+     * </ul>
+     */
+    class ModLocalFileSystem:ModBaseClass
+    {
+    public:
+
+        ModLocalFileSystem(const char* i_path);
+        ModLocalFileSystem();
+        virtual ~ModLocalFileSystem();
+        void setParam(const char* i_path);
+        bool execute(HttpdConnection& i_connection);
+    };
+
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/mod/ModMiMicSetting.cpp	Tue Jul 09 12:07:17 2013 +0000
@@ -0,0 +1,38 @@
+#include "ModMiMicSetting.h"
+#include "HttpdConnection.h"
+#include "NyLPC_net.h"
+
+namespace MiMic
+{
+    ModMiMicSetting::ModMiMicSetting(const char* i_path):ModBaseClass(i_path)
+    {
+    }
+    ModMiMicSetting::ModMiMicSetting():ModBaseClass()
+    {
+    }
+    ModMiMicSetting::~ModMiMicSetting()
+    {
+    }
+    void ModMiMicSetting::setParam(const char* i_path)
+    {
+        ModBaseClass::setParam(i_path);
+    }
+    bool ModMiMicSetting::execute(HttpdConnection& i_connection)
+    {
+        NyLPC_TcModMiMicSetting_t mod;
+
+        //check parametor
+        if(this->_path==NULL){
+            return false;
+        }
+        NyLPC_cModMiMicSetting_initialize(&mod,this->_path);
+        if(NyLPC_cModMiMicSetting_canHandle(&mod,i_connection._ref_inst)){
+            NyLPC_cModMiMicSetting_execute(&mod,i_connection._ref_inst);
+            NyLPC_cModMiMicSetting_finalize(&mod);
+            return true;
+        }
+        NyLPC_cModMiMicSetting_finalize(&mod);
+        return false;
+    }
+
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/mod/ModMiMicSetting.h	Tue Jul 09 12:07:17 2013 +0000
@@ -0,0 +1,42 @@
+#pragma once
+////////////////////////////////////////////////////////////////////////////////
+// ModMiMicSetting.h
+////////////////////////////////////////////////////////////////////////////////
+
+#include "NyLPC_net.h"
+#include "ModBaseClass.h"
+
+
+namespace MiMic
+{
+    class HttpdConnection;
+    /**
+     * This class is a module for Httpd.
+     * The class provides an REST-API to set and get the on-chip configuration MiMicHttpd.
+     * The class is wrapper of NyLPC_TcModMiMicSetting class.
+     */
+    class ModMiMicSetting :ModBaseClass
+    {
+    public:
+        /**
+         * Constructor with parameter initialization.
+         */
+        ModMiMicSetting(const char* i_path);
+        /**
+         * Default constructor.
+         * Must be call {@link setParam} function after constructed.
+         */
+        ModMiMicSetting();
+        virtual ~ModMiMicSetting();
+        void setParam(const char* i_path);
+        /**
+          * This function processes a request. 
+          * The function checks whether a connection has a target request.
+          * If necessary, it will transmit a response.
+          * @return
+          * TRUE if request was processed. otherwise FALSE.
+          */
+        bool execute(HttpdConnection& i_connection);
+    };
+
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/mod/ModRemoteMcu.cpp	Tue Jul 09 12:07:17 2013 +0000
@@ -0,0 +1,37 @@
+#include "ModRemoteMcu.h"
+#include "HttpdConnection.h"
+
+namespace MiMic
+{
+    ModRemoteMcu::ModRemoteMcu(const char* i_path):ModBaseClass(i_path)
+    {
+    }
+    ModRemoteMcu::ModRemoteMcu()
+    {
+    }
+    ModRemoteMcu::~ModRemoteMcu()
+    {
+    }
+    void ModRemoteMcu::setParam(const char* i_path)
+    {
+        ModBaseClass::setParam(i_path);
+    }
+    bool ModRemoteMcu::execute(HttpdConnection& i_connection)
+    {
+        NyLPC_TcModRemoteMcu_t mod;
+
+        //check parametor
+        if(this->_path==NULL){
+            return false;
+        }
+        NyLPC_cModRemoteMcu_initialize(&mod,this->_path);
+        if(NyLPC_cModRemoteMcu_canHandle(&mod,i_connection._ref_inst)){
+            NyLPC_cModRemoteMcu_execute(&mod,i_connection._ref_inst);
+            NyLPC_cModRemoteMcu_finalize(&mod);
+            return true;
+        }
+        NyLPC_cModRemoteMcu_finalize(&mod);
+        return false;
+    }
+
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/mod/ModRemoteMcu.h	Tue Jul 09 12:07:17 2013 +0000
@@ -0,0 +1,42 @@
+#pragma once
+////////////////////////////////////////////////////////////////////////////////
+// ModRemoteMcu.h
+////////////////////////////////////////////////////////////////////////////////
+
+#include "NyLPC_net.h"
+#include "ModBaseClass.h"
+
+
+namespace MiMic
+{
+    class HttpdConnection;
+    /**
+     * This class is a module for Httpd.
+     * The class provides an REST-API to execute MiMic ByteCode.
+     * The class is wrapper of NyLPC_TcModRemoteMcu class.
+     */
+    class ModRemoteMcu:ModBaseClass
+    {
+    public:
+        /**
+         * Constructor with parameter initialization.
+         */
+        ModRemoteMcu(const char* i_path);
+        /**
+         * Default constructor.
+         * Must be call {@link setParam} function after constructed.
+         */
+        ModRemoteMcu();
+        virtual ~ModRemoteMcu();
+        void setParam(const char* i_path);
+        /**
+          * This function processes a request. 
+          * The function checks whether a connection has a target request.
+          * If necessary, it will transmit a response.
+          * @return
+          * TRUE if request was processed. otherwise FALSE.
+          */
+        bool execute(HttpdConnection& i_connection);
+    };
+
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/mod/ModRomFiles.cpp	Tue Jul 09 12:07:17 2013 +0000
@@ -0,0 +1,39 @@
+#include "ModRomFiles.h"
+#include "HttpdConnection.h"
+
+namespace MiMic
+{
+    ModRomFiles::ModRomFiles(const char* i_path,const NyLPC_TRomFileData* i_ref_fsdata,unsigned short i_num):ModBaseClass(i_path)
+    {
+    }
+    ModRomFiles::ModRomFiles():ModBaseClass()
+    {
+    }
+    ModRomFiles::~ModRomFiles()
+    {
+    }
+    void ModRomFiles::setParam(const char* i_path,const NyLPC_TRomFileData* i_ref_fsdata,unsigned short i_num)
+    {
+        ModBaseClass::setParam(i_path);
+        this->_ref_fsdata=i_ref_fsdata;
+        this->_num=i_num;
+    }
+    bool ModRomFiles::execute(HttpdConnection& i_connection)
+    {
+        NyLPC_TcModRomFiles_t mod;
+
+        //check parametor
+        if(this->_path==NULL){
+            return false;
+        }
+        NyLPC_cModRomFiles_initialize(&mod,this->_path,this->_ref_fsdata,this->_num);
+        if(NyLPC_cModRomFiles_canHandle(&mod,i_connection._ref_inst)){
+            NyLPC_cModRomFiles_execute(&mod,i_connection._ref_inst);
+            NyLPC_cModRomFiles_finalize(&mod);
+            return true;
+        }
+        NyLPC_cModRomFiles_finalize(&mod);
+        return false;
+    }
+
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/mod/ModRomFiles.h	Tue Jul 09 12:07:17 2013 +0000
@@ -0,0 +1,52 @@
+#pragma once
+////////////////////////////////////////////////////////////////////////////////
+// ModRomFiles.h
+////////////////////////////////////////////////////////////////////////////////
+
+#include "NyLPC_net.h"
+#include "ModBaseClass.h"
+
+
+namespace MiMic
+{
+    class HttpdConnection;
+    /**
+     * This class is a module for Httpd.
+     * The class sends file image which is stored on ROM.
+     * The class is wrapper of NyLPC_tcModRomFiles class.
+     */
+    class ModRomFiles:ModBaseClass
+    {
+    private:
+        const NyLPC_TRomFileData* _ref_fsdata;
+        unsigned short _num;
+    public:
+        /**
+         * Constructor with parameter initialization.
+         */
+        ModRomFiles(const char* i_path,const NyLPC_TRomFileData* i_ref_fsdata,unsigned short i_num);
+        /**
+         * Default constructor.
+         * Must be call {@link setParam} function after constructed.
+         */
+        ModRomFiles();
+        virtual ~ModRomFiles();
+        /**
+         * @param i_path
+         * target path
+         * <pre>
+         * ex.setParam("setup")
+         * </pre>
+         */
+        void setParam(const char* i_path,const NyLPC_TRomFileData* i_ref_fsdata,unsigned short i_num);
+        /**
+          * This function processes a request. 
+          * The function checks whether a connection has a target request.
+          * If necessary, it will transmit a response.
+          * @return
+          * TRUE if request was processed. otherwise FALSE.
+          */
+        bool execute(HttpdConnection& i_connection);
+    };
+
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/mod/ModUrl.cpp	Tue Jul 09 12:07:17 2013 +0000
@@ -0,0 +1,29 @@
+#include "ModUrl.h"
+#include "HttpdConnection.h"
+
+namespace MiMic
+{
+    ModUrl::ModUrl()
+    {
+    }
+    ModUrl::~ModUrl()
+    {
+    }
+    bool ModUrl::execute(HttpdConnection& i_connection,char* o_url_buf,int i_buf_len,int* o_method_type)
+    {
+        NyLPC_TcModUrl_t mod;
+        if(i_buf_len<1){
+            return false;
+        }
+        NyLPC_cModUrl_initialize(&mod);
+        if(!NyLPC_cModUrl_execute(&mod,i_connection._ref_inst,o_url_buf,i_buf_len)){
+            *o_url_buf='\0';
+        }
+        if(o_method_type!=NULL){
+            *o_method_type=NyLPC_cModUrl_getMethod(&mod);
+        }
+        NyLPC_cModUrl_finalize(&mod);
+        return true;
+    }
+
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/mod/ModUrl.h	Tue Jul 09 12:07:17 2013 +0000
@@ -0,0 +1,50 @@
+#pragma once
+////////////////////////////////////////////////////////////////////////////////
+// ModRomFiles.h
+////////////////////////////////////////////////////////////////////////////////
+
+#include "NyLPC_net.h"
+
+
+namespace MiMic
+{
+    class HttpdConnection;
+    /**
+     * This class is a module for Httpd.
+     * The class parses a request path to buffer from connection.
+     */
+    class ModUrl
+    {
+    private:
+        int _method_type;
+    public:
+        const static int METHOD_GET =NyLPC_THttpMethodType_GET;
+        const static int METHOD_HEAD=NyLPC_THttpMethodType_HEAD;
+        const static int METHOD_POST=NyLPC_THttpMethodType_POST;
+    public:
+        /**
+         * Constructor.
+         */
+        ModUrl();
+        virtual ~ModUrl();
+
+        /**
+          * This function processes a request.
+          * @param i_connection
+          * @param o_url_buf
+          * Output parametor.
+          * Address of buffer which accept URL string.
+          * The string will be "" (zero text) if URL too long or parsing failed. 
+          * @param i_buf_len
+          * Size of o_url buffer in byte.
+          * @param o_method_type
+          * Address of variable which accept HTTP-Method type.
+          * Can be omitted.
+          * @return
+          * TRUE if request was processed. otherwise FALSE.
+          * The value describes processing status. It is not parsing error status.
+          */
+        bool execute(HttpdConnection& i_connection,char* o_url_buf,int i_buf_len,int* o_method_type=NULL);
+    };
+
+}
\ No newline at end of file