Permalink
Browse files

Added custom server header support

  • Loading branch information...
1 parent e42eeda commit ca12cb56c89c7f3c8bba182b15e99ba3a60ce0c1 @gbrindisi committed Jun 16, 2015
Showing with 16 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +1 −0 wordpot.conf
  3. +14 −0 wordpot/__init__.py
View
@@ -3,4 +3,5 @@
*.pyc
!.gitignore
/env
+/venv
View
@@ -5,6 +5,7 @@
HOST = '127.0.0.1' # Hostname
PORT = '80' # Port
THEME = 'twentyeleven' # Theme name in use
+SERVER = 'Apache/2.2.22 (Ubuntu)' # Custom server header
# -----------------------
# Wordpress configuration
View
@@ -46,6 +46,7 @@ def parse_options():
parser.add_option('--plugins', dest='PLUGINS', help='Fake installed plugins')
parser.add_option('--themes', dest='THEMES', help='Fake installed themes')
parser.add_option('--ver', dest='VERSION', help='Wordpress version')
+ parser.add_option('--server', dest='SERVER', help='Custom "Server" header')
(options, args) = parser.parse_args()
@@ -55,6 +56,7 @@ def parse_options():
val = [ v.strip() for v in val.split(',') ]
app.config[opt] = val
+
def check_options():
for k, v in REQUIRED_OPTIONS.iteritems():
if k not in app.config:
@@ -96,6 +98,18 @@ def check_options():
else:
LOGGER.warn('hpfeeds is disabled')
+
+# ------------------------
+# Add Custom Server Header
+#-------------------------
+
+@app.after_request
+def add_server_header(response):
+ if app.config['SERVER']:
+ response.headers['Server'] = app.config['SERVER']
+
+ return response
+
# ----------------------------
# Building the plugins manager
# ----------------------------

0 comments on commit ca12cb5

Please sign in to comment.