File: adjust-server-name.patch

package info (click to toggle)
workflow 0.11.10-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,756 kB
  • sloc: cpp: 33,792; ansic: 9,393; makefile: 9; sh: 6
file content (45 lines) | stat: -rw-r--r-- 1,392 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
Description: Append server name to HTTP response
Author: Lance Lin <lq27267@gmail.com>
Forwarded: not-needed
Date: 15 Aug 2022

--- a/src/protocol/HttpMessage.h
+++ b/src/protocol/HttpMessage.h
@@ -74,9 +74,17 @@
 
 	bool add_header_pair(const char *name, const char *value)
 	{
+		if(strcmp(name, "Server") == 0) {
+			std::string append = value;
+			append += " - powered by Workflow v0.10";
+			return http_parser_add_header(name, strlen(name), 
+					              append.c_str(), append.length(),
+						      this->parser) == 0;
+		} else {
 		return http_parser_add_header(name, strlen(name),
-									  value, strlen(value),
-									  this->parser) == 0;
+					      value, strlen(value),
+					      this->parser) == 0;
+		}
 	}
 
 	bool set_header(const struct HttpMessageHeader *header)
@@ -149,9 +157,17 @@
 
 	bool add_header_pair(const std::string& name, const std::string& value)
 	{
+		if(strcmp(name.c_str(), "Server") == 0) {
+			std::string append = value;
+			append += " - powered by Workflow v0.10";
+			return http_parser_add_header(name.c_str(), name.size(),
+						      append.c_str(), append.size(),
+						     this->parser) == 0;
+		} else {
 		return http_parser_add_header(name.c_str(), name.size(),
 									  value.c_str(), value.size(),
 									  this->parser) == 0;
+		}
 	}
 
 	bool set_header_pair(const std::string& name, const std::string& value)