[sheepdog] [PATCH 4/4] http: simplify http_run_request

Liu Yuan namei.unix at gmail.com
Thu Nov 14 10:03:54 CET 2013


Signed-off-by: Liu Yuan <namei.unix at gmail.com>
---
 sheep/http/http.c |   22 ++++++----------------
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/sheep/http/http.c b/sheep/http/http.c
index 644cdc5..e9afedc 100644
--- a/sheep/http/http.c
+++ b/sheep/http/http.c
@@ -209,37 +209,27 @@ static void http_run_request(struct work *work)
 	struct http_driver *hdrv;
 
 	list_for_each_entry(hdrv, &http_enabled_drivers, list) {
-		void (*method)(struct http_request *req) = NULL;
-
 		switch (op) {
 		case HTTP_HEAD:
-			method = hdrv->head;
+			hdrv->head(req);
 			break;
 		case HTTP_GET:
-			method = hdrv->get;
+			hdrv->get(req);
 			break;
 		case HTTP_PUT:
-			method = hdrv->put;
+			hdrv->put(req);
 			break;
 		case HTTP_POST:
-			method = hdrv->post;
+			hdrv->post(req);
 			break;
 		case HTTP_DELETE:
-			method = hdrv->delete;
+			hdrv->delete(req);
 			break;
 		default:
+			http_response_header(req, METHOD_NOT_ALLOWED);
 			break;
 		}
-
-		if (method != NULL) {
-			method(req);
-			if (req->status != UNKNOWN)
-				goto out;
-		}
 	}
-
-	http_response_header(req, METHOD_NOT_ALLOWED);
-out:
 	http_end_request(req);
 }
 
-- 
1.7.9.5




More information about the sheepdog mailing list