[groonga-dev,00265] [PATCH] Bad Request対応

Back to archive index

Kouhei Sutou kou****@clear*****
2009年 11月 9日 (月) 15:09:41 JST


須藤です。

HTTPでリクエストするパスが"/"から始まっていないとき(RFC2396
のabs_path以外のとき)に400 Bad Requestを返すパッチです。

HTTPインターフェイスの部分はこれから変更が入りそうなので、今
の段階では、とりあえず、対応しておかなくてもよいかもしれませ
んが。。。

diff --git a/src/groonga.c b/src/groonga.c
index 9f65dc4..f20a1af 100644
--- a/src/groonga.c
+++ b/src/groonga.c
@@ -278,6 +278,15 @@ do_htreq(grn_ctx *ctx, grn_edge *edge)
       if (*path == '/') {
         put_response_header(ctx, path, p);
         grn_ctx_send(ctx, path, p - path, 0);
+      } else {
+        grn_obj *response = ctx->impl->outbuf;
+        GRN_TEXT_SETS(ctx, response, "HTTP/1.1 400 Bad Request\r\n");
+        GRN_TEXT_PUTS(ctx, response, "Connection: close\r\n");
+        GRN_TEXT_PUTS(ctx, response, "Contest-Type: text/plain\r\n");
+        GRN_TEXT_PUTS(ctx, response, "\r\n");
+        GRN_TEXT_PUTS(ctx, response,
+                      "Bad Request: Your request path doesn't start with '/'.");
+        ctx->impl->output(ctx, 0, ctx->impl->data.ptr);
       }
     }
     break;
-- 
--------------------------------------------------------
各種ブラウザ向けツールバーやプラグインの開発を承ります。
また、ブラウザからICカードやカメラなどのハードウェアへ
アクセスする機能の開発も承ります。
--------------------------------------------------------
  株式会社クリアコード 須藤功平 <kou****@clear*****>
    Tel: 03(6231)7270 URL: http://www.clear-code.com/
--------------------------------------------------------




groonga-dev メーリングリストの案内
Back to archive index