Merge ~cjwatson/launchpad:loggerhead-fix-robots into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 318b67fbdbd6ae17d9eea1725e471bcd10a94f2a
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:loggerhead-fix-robots
Merge into: launchpad:master
Diff against target: 31 lines (+8/-1)
2 files modified
lib/launchpad_loggerhead/app.py (+1/-1)
lib/launchpad_loggerhead/tests.py (+7/-0)
Reviewer Review Type Date Requested Status
Ines Almeida Approve
Review via email: mp+442782@code.launchpad.net

Commit message

launchpad_loggerhead: Fix robots.txt

Description of the change

On Python 3, the response to a request for `robots.txt` needs to be bytes or Gunicorn rejects it.

We didn't notice this on production or staging because this file is served via an Apache `Alias` directive rather than going via the appserver, but fixing it seems to make sense anyway.

To post a comment you must log in.
Revision history for this message
Ines Almeida (ines-almeida) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/launchpad_loggerhead/app.py b/lib/launchpad_loggerhead/app.py
2index 20549b4..b7496ae 100644
3--- a/lib/launchpad_loggerhead/app.py
4+++ b/lib/launchpad_loggerhead/app.py
5@@ -34,7 +34,7 @@ from lp.services.webapp.errorlog import ErrorReportingUtility
6 from lp.services.webapp.vhosts import allvhosts
7 from lp.xmlrpc import faults
8
9-robots_txt = """\
10+robots_txt = b"""\
11 User-agent: *
12 Disallow: /
13 """
14diff --git a/lib/launchpad_loggerhead/tests.py b/lib/launchpad_loggerhead/tests.py
15index 1bc5fae..ba788ff 100644
16--- a/lib/launchpad_loggerhead/tests.py
17+++ b/lib/launchpad_loggerhead/tests.py
18@@ -191,6 +191,13 @@ class TestWSGI(TestCaseWithFactory):
19 "loggerhead-debug", Content(UTF8_TEXT, get_debug_log_bytes)
20 )
21
22+ def test_robots(self):
23+ response = requests.get(
24+ "http://127.0.0.1:%d/robots.txt" % config.codebrowse.port
25+ )
26+ self.assertEqual(200, response.status_code)
27+ self.assertEqual(b"User-agent: *\nDisallow: /\n", response.content)
28+
29 def test_public_port_public_branch(self):
30 # Requests for public branches on the public port are allowed.
31 db_branch, _ = self.create_branch_and_tree()

Subscribers

People subscribed via source and target branches

to status/vote changes: