[Groonga-commit] groonga/groonga at 03049cd [master] groonga-httpd: extract a function to send bytes to the groonga context from ngx_http_groonga_handler_process_body

Back to archive index

Motoi Washida null+****@clear*****
Sun Aug 18 14:59:21 JST 2013


Motoi Washida	2013-08-18 14:59:21 +0900 (Sun, 18 Aug 2013)

  New Revision: 03049cd9d4e8dcf0029862605d5c9a61e14cc1c3
  https://github.com/groonga/groonga/commit/03049cd9d4e8dcf0029862605d5c9a61e14cc1c3

  Merged 3eb016a: Merge pull request #101 from wm3/httpd-posts-doesnt-work-bug

  Message:
    groonga-httpd: extract a function to send bytes to the groonga context from ngx_http_groonga_handler_process_body

  Modified files:
    src/httpd/nginx-module/ngx_http_groonga_module.c

  Modified: src/httpd/nginx-module/ngx_http_groonga_module.c (+33 -16)
===================================================================
--- src/httpd/nginx-module/ngx_http_groonga_module.c    2013-08-17 22:30:12 +0900 (7b9744a)
+++ src/httpd/nginx-module/ngx_http_groonga_module.c    2013-08-18 14:59:21 +0900 (0a416fa)
@@ -331,26 +331,16 @@ ngx_http_groonga_handler_validate_post_command(ngx_http_request_t *r,
 }
 
 static ngx_int_t
-ngx_http_groonga_handler_process_body(ngx_http_request_t *r,
-                                      ngx_http_groonga_handler_data_t *data)
+ngx_http_groonga_send_lines(grn_ctx *context,
+                            ngx_http_request_t *r,
+                            u_char *current,
+                            u_char *last)
 {
   ngx_int_t rc;
 
-  grn_ctx *context;
-
-  ngx_buf_t *body;
-  u_char *line_start, *current;
-
-  context = &(data->context);
-
-  body = r->request_body->bufs->buf;
-  if (!body) {
-    ngx_http_groonga_handler_set_content_type(r, "text/plain");
-    GRN_TEXT_PUTS(context, &(data->body), "must send load data as body");
-    return NGX_HTTP_BAD_REQUEST;
-  }
+  u_char *line_start;
 
-  for (line_start = current = body->pos; current < body->last; current++) {
+  for (line_start = current; current < last; current++) {
     if (*current != '\n') {
       continue;
     }
@@ -375,6 +365,33 @@ ngx_http_groonga_handler_process_body(ngx_http_request_t *r,
   return NGX_OK;
 }
 
+static ngx_int_t
+ngx_http_groonga_handler_process_body(ngx_http_request_t *r,
+                                      ngx_http_groonga_handler_data_t *data)
+{
+  ngx_int_t rc;
+
+  grn_ctx *context;
+
+  ngx_buf_t *body;
+
+  context = &(data->context);
+
+  body = r->request_body->bufs->buf;
+  if (!body) {
+    ngx_http_groonga_handler_set_content_type(r, "text/plain");
+    GRN_TEXT_PUTS(context, &(data->body), "must send load data as body");
+    return NGX_HTTP_BAD_REQUEST;
+  }
+
+  rc = ngx_http_groonga_send_lines(context, r, body->pos, body->last);
+  if (rc != NGX_OK) {
+    return rc;
+  }
+
+  return NGX_OK;
+}
+
 
 static ngx_int_t
 ngx_http_groonga_handler_process_load(ngx_http_request_t *r,
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index