From df206bc05a3d3c99900c9cf44dc598c4813fc92a Mon Sep 17 00:00:00 2001
From: MPR <michel.promonet@free.fr>
Date: Sat, 11 Oct 2014 17:56:35 +0200
Subject: [PATCH] transmit http answer code using http_client

---
 examples/http_client/http_client.c | 1 +
 mongoose.c                         | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/examples/http_client/http_client.c b/examples/http_client/http_client.c
index 3f89d8ae6..41eac581e 100644
--- a/examples/http_client/http_client.c
+++ b/examples/http_client/http_client.c
@@ -36,6 +36,7 @@ static int ev_handler(struct mg_connection *conn, enum mg_event ev) {
     case MG_REPLY:
       // Send reply to the original connection
       orig = (struct mg_connection *) conn->connection_param;
+      mg_send_status(orig, conn->status_code);
       mg_send_header(orig, "Content-Type", "text/plain");
       mg_send_data(orig, conn->content, conn->content_len);
       mg_send_data(orig, "", 0);  // Last chunk: mark the end of reply
diff --git a/mongoose.c b/mongoose.c
index 76048b282..4048a790f 100644
--- a/mongoose.c
+++ b/mongoose.c
@@ -2410,6 +2410,9 @@ static int parse_http_message(char *buf, int len, struct mg_connection *ri) {
     if (is_request) {
       ri->http_version += 5;
     }
+    else {
+      ri->status_code = atoi(ri->uri);
+    }
     parse_http_headers(&buf, ri);
 
     if ((ri->query_string = strchr(ri->uri, '?')) != NULL) {
-- 
GitLab