aboutsummaryrefslogtreecommitdiffstats
path: root/extras
diff options
context:
space:
mode:
authorAdrian Villin <avillin@cisco.com>2024-08-16 15:23:28 +0200
committerFlorin Coras <florin.coras@gmail.com>2024-08-22 06:09:43 +0000
commit7e6606ab4ea9501195b234fb14077ef4950f8d4e (patch)
treedabd65e48f4d17a07dc700a323e1b516a198c0e3 /extras
parent8792e5c5c5e8e4f6c514ff81c97a7fb31890d657 (diff)
http_static: added last-modified header
Type: improvement Change-Id: I492df92ef25f9c0cd57fc8980500b58bebaa94c6 Signed-off-by: Adrian Villin <avillin@cisco.com>
Diffstat (limited to 'extras')
-rw-r--r--extras/hs-test/http_test.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/extras/hs-test/http_test.go b/extras/hs-test/http_test.go
index ffdcf930b8e..872f4c234b3 100644
--- a/extras/hs-test/http_test.go
+++ b/extras/hs-test/http_test.go
@@ -553,6 +553,8 @@ func HttpStaticFileHandlerTestFunction(s *NoTopoSuite, max_age string) {
content := "<html><body><p>Hello</p></body></html>"
content2 := "<html><body><p>Page</p></body></html>"
+ currentDate := time.Now().In(time.FixedZone("GMT", 0)).Format(http.TimeFormat)[:17]
+
vpp := s.GetContainerByName("vpp").VppInstance
vpp.Container.Exec("mkdir -p " + wwwRootPath)
err := vpp.Container.CreateFile(wwwRootPath+"/index.html", content)
@@ -568,11 +570,16 @@ func HttpStaticFileHandlerTestFunction(s *NoTopoSuite, max_age string) {
resp, err := client.Do(req)
s.AssertNil(err, fmt.Sprint(err))
defer resp.Body.Close()
+
s.Log(DumpHttpResp(resp, true))
s.AssertEqual(200, resp.StatusCode)
s.AssertContains(resp.Header.Get("Content-Type"), "html")
s.AssertContains(resp.Header.Get("Cache-Control"), "max-age="+max_age)
+ // only checking date
+ s.AssertContains(resp.Header.Get("Last-Modified"), currentDate)
+ s.AssertEqual(len(resp.Header.Get("Last-Modified")), 29)
s.AssertEqual(int64(len([]rune(content))), resp.ContentLength)
+
body, err := io.ReadAll(resp.Body)
s.AssertNil(err, fmt.Sprint(err))
s.AssertEqual(string(body), content)
@@ -589,6 +596,7 @@ func HttpStaticFileHandlerTestFunction(s *NoTopoSuite, max_age string) {
s.AssertContains(resp.Header.Get("Content-Type"), "html")
s.AssertContains(resp.Header.Get("Cache-Control"), "max-age="+max_age)
s.AssertEqual(int64(len([]rune(content))), resp.ContentLength)
+
body, err = io.ReadAll(resp.Body)
s.AssertNil(err, fmt.Sprint(err))
s.AssertEqual(string(body), content)
@@ -603,6 +611,7 @@ func HttpStaticFileHandlerTestFunction(s *NoTopoSuite, max_age string) {
s.AssertContains(resp.Header.Get("Content-Type"), "html")
s.AssertContains(resp.Header.Get("Cache-Control"), "max-age="+max_age)
s.AssertEqual(int64(len([]rune(content2))), resp.ContentLength)
+
body, err = io.ReadAll(resp.Body)
s.AssertNil(err, fmt.Sprint(err))
s.AssertEqual(string(body), content2)
@@ -828,7 +837,7 @@ func HttpStaticBuildInUrlPostIfStatsTest(s *NoTopoSuite) {
}
func HttpStaticMacTimeTest(s *NoTopoSuite) {
- currentDate := time.Now().In(time.FixedZone("GMT", 0)).Format(http.TimeFormat)
+ currentDate := time.Now().In(time.FixedZone("GMT", 0)).Format(http.TimeFormat)[:17]
vpp := s.GetContainerByName("vpp").VppInstance
serverAddress := s.GetInterfaceByName(TapInterfaceName).Peer.Ip4AddressString()
s.Log(vpp.Vppctl("http static server uri tcp://" + serverAddress + "/80 url-handlers debug"))
@@ -848,6 +857,8 @@ func HttpStaticMacTimeTest(s *NoTopoSuite) {
s.AssertContains(string(data), s.GetInterfaceByName(TapInterfaceName).Ip4AddressString())
s.AssertContains(string(data), s.GetInterfaceByName(TapInterfaceName).HwAddress.String())
s.AssertContains(resp.Header.Get("Content-Type"), "json")
+ s.AssertEqual(len(resp.Header.Get("Date")), 29)
+ // only checking date
s.AssertContains(resp.Header.Get("Date"), currentDate)
}