This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
     new 6e0da45  feature: add apisix-version info to headers in APISIX core 
(#1961)
6e0da45 is described below

commit 6e0da454d1b5291e6ee22b9b05b254de056b63c5
Author: Swayam Raina <swayamra...@gmail.com>
AuthorDate: Sat Aug 15 04:54:33 2020 +0530

    feature: add apisix-version info to headers in APISIX core (#1961)
    
    related #1877
---
 apisix/init.lua            | 5 ++++-
 t/node/remote-addr-ipv6.t  | 1 +
 t/plugin/redirect.t        | 1 +
 t/router/multi-ssl-certs.t | 1 +
 t/router/radixtree-sni.t   | 3 +++
 5 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/apisix/init.lua b/apisix/init.lua
index 4ec618f..a285cc6 100644
--- a/apisix/init.lua
+++ b/apisix/init.lua
@@ -23,7 +23,7 @@ local service_fetch = require("apisix.http.service").get
 local admin_init    = require("apisix.admin.init")
 local get_var       = require("resty.ngxvar").fetch
 local router        = require("apisix.router")
-local set_upstream = require("apisix.upstream").set_by_route
+local set_upstream  = require("apisix.upstream").set_by_route
 local ipmatcher     = require("resty.ipmatcher")
 local ngx           = ngx
 local get_method    = ngx.req.get_method
@@ -40,6 +40,7 @@ local load_balancer
 local local_conf
 local dns_resolver
 local lru_resolved_domain
+local ver_header    = "APISIX/" .. core.version.VERSION
 
 
 local function parse_args(args)
@@ -301,6 +302,8 @@ function _M.http_access_phase()
 
     core.ctx.set_vars_meta(api_ctx)
 
+    core.response.set_header("Server", ver_header)
+
     -- load and run global rule
     if router.global_rules and router.global_rules.values
        and #router.global_rules.values > 0 then
diff --git a/t/node/remote-addr-ipv6.t b/t/node/remote-addr-ipv6.t
index 26e4830..c4faa94 100644
--- a/t/node/remote-addr-ipv6.t
+++ b/t/node/remote-addr-ipv6.t
@@ -114,6 +114,7 @@ request sent: 59
 received: HTTP/1.1 200 OK
 received: Content-Type: text/plain
 received: Connection: close
+received: Server: APISIX/\d\.\d+(\.\d+)?
 received: Server: \w+
 received: 
 received: hello world
diff --git a/t/plugin/redirect.t b/t/plugin/redirect.t
index 1415db2..c624be8 100644
--- a/t/plugin/redirect.t
+++ b/t/plugin/redirect.t
@@ -669,6 +669,7 @@ sent http request: 58 bytes.
 received: HTTP/1.1 200 OK
 received: Content-Type: text/plain
 received: Connection: close
+received: Server: APISIX/\d\.\d+(\.\d+)?
 received: Server: \w+
 received: \nreceived: hello world
 close: 1 nil}
diff --git a/t/router/multi-ssl-certs.t b/t/router/multi-ssl-certs.t
index 6c968cb..d887535 100644
--- a/t/router/multi-ssl-certs.t
+++ b/t/router/multi-ssl-certs.t
@@ -160,6 +160,7 @@ sent http request: 62 bytes.
 received: HTTP/1.1 200 OK
 received: Content-Type: text/plain
 received: Connection: close
+received: Server: APISIX/\d\.\d+(\.\d+)?
 received: Server: \w+
 received: \nreceived: hello world
 close: 1 nil}
diff --git a/t/router/radixtree-sni.t b/t/router/radixtree-sni.t
index 5fe1ccd..80e1a5b 100644
--- a/t/router/radixtree-sni.t
+++ b/t/router/radixtree-sni.t
@@ -160,6 +160,7 @@ sent http request: 62 bytes.
 received: HTTP/1.1 200 OK
 received: Content-Type: text/plain
 received: Connection: close
+received: Server: APISIX/\d\.\d+(\.\d+)?
 received: Server: \w+
 received: \nreceived: hello world
 close: 1 nil}
@@ -313,6 +314,7 @@ sent http request: 62 bytes.
 received: HTTP/1.1 200 OK
 received: Content-Type: text/plain
 received: Connection: close
+received: Server: APISIX/\d\.\d+(\.\d+)?
 received: Server: \w+
 received: \nreceived: hello world
 close: 1 nil}
@@ -426,6 +428,7 @@ sent http request: 58 bytes.
 received: HTTP/1.1 200 OK
 received: Content-Type: text/plain
 received: Connection: close
+received: Server: APISIX/\d\.\d+(\.\d+)?
 received: Server: \w+
 received: \nreceived: hello world
 close: 1 nil}

Reply via email to