Skip to content

Commit 1374704

Browse files
committed
added Content-Length header to tests, passing locally
1 parent dfe0fb4 commit 1374704

File tree

8 files changed

+31
-34
lines changed

8 files changed

+31
-34
lines changed

frameworks/Python/historical/install.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ export PIP_DOWNLOAD_CACHE=$IROOT/.pip_cache
88

99
fw_depends python2 apache
1010

11+
$PY2_PIP install --install-option="--prefix=${PY2_ROOT}" -r $TROOT/webware/requirements.txt
12+
1113
cd $TROOT/webware
1214
rm -fr Webware Webware-1.1.1
1315
rm Webware-1.1.1.tar.gz
1416
wget downloads.sourceforge.net/webware/Webware-1.1.1.tar.gz
1517
tar -xf Webware-1.1.1.tar.gz
1618
cp -r app/ Webware-1.1.1/
17-
#rm -fr Webware-1.1.1/WebKit/Configs
18-
#cp -r app/Configs/ Webware-1.1.1/WebKit/Configs/

frameworks/Python/historical/webware/app/Context/__init__.py

Lines changed: 0 additions & 5 deletions
This file was deleted.

frameworks/Python/historical/webware/app/Context/db.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@ def defaultAction(self):
1111
self.response()._headers["Content-Type"] = "application/json"
1212
wid = randint(1, 10000)
1313
world = Database.DbSession.query(World).get(wid).serialize()
14-
self.write(json.dumps(world))
14+
output = json.dumps(world)
15+
self.response()._headers["Content-Length"] = len(output)
16+
self.write(output)

frameworks/Python/historical/webware/app/Context/fortune.py

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,16 @@
88
from Fortune import Fortune
99

1010
class fortune(Page):
11-
def writeDocType(self):
12-
self.writeln("<!DOCTYPE html>")
13-
14-
def title(self):
15-
return "Fortunes"
16-
17-
def htBodyArgs(self):
18-
return ""
19-
20-
def writeContent(self):
21-
self.response().clearHeaders()
22-
self.response()._headers["Content-Type"] = "text/html; charset=UTF-8"
23-
fortunes = Database.DbSession.query(Fortune).all()
24-
fortunes.append(Fortune(id=0, message="Additional fortune added at request time."))
25-
fortunes.sort(key=attrgetter("message"))
26-
27-
self.writeln("<table><tr><th>id</th><th>message</th></tr>")
28-
for fortune in fortunes:
29-
message = bleach.clean(fortune.message)
30-
self.writeln("<tr><td>%s</td><td>%s</td></tr>" % (fortune.id , message.encode("utf-8")))
31-
self.writeln("</table>")
11+
def writeHTML(self):
12+
output = "<!DOCTYPE html><html><head><title>Fortunes</title></head><body><table><tr><th>id</th><th>message</th></tr>"
13+
self.response().clearHeaders()
14+
self.response()._headers["Content-Type"] = "text/html; charset=UTF-8"
15+
fortunes = Database.DbSession.query(Fortune).all()
16+
fortunes.append(Fortune(id=0, message="Additional fortune added at request time."))
17+
fortunes.sort(key=attrgetter("message"))
18+
for fortune in fortunes:
19+
message = bleach.clean(fortune.message)
20+
output += "<tr><td>%s</td><td>%s</td></tr>" % (fortune.id , message.encode("utf-8"))
21+
output += "</table></body></html>"
22+
self.response()._headers["Content-Length"] = len(output)
23+
self.writeln(output)

frameworks/Python/historical/webware/app/Context/json2.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@
55
class json2(HTTPContent):
66
def defaultAction(self):
77
self.response().clearHeaders()
8-
self.response()._headers["Content-Type"] = "application/json"
9-
self.write(json.dumps({"message": "Hello, World!"}))
8+
self.response()._headers["Content-Type"] = "application/json"
9+
output = json.dumps({"message": "Hello, World!"})
10+
self.response()._headers["Content-Length"] = len(output)
11+
self.write(output)

frameworks/Python/historical/webware/app/Context/plaintext.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ class plaintext(HTTPContent):
55
def defaultAction(self):
66
self.response().clearHeaders()
77
self.response()._headers["Content-Type"] = "text/plain"
8-
self.write("Hello, World!")
8+
output = "Hello, World!"
9+
self.response()._headers["Content-Length"] = len(output)
10+
self.write(output)

frameworks/Python/historical/webware/app/Context/queries.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,6 @@ def defaultAction(self):
1515
rp = partial(randint, 1, 10000)
1616
get = Database.DbSession.query(World).get
1717
worlds = [get(rp()).serialize() for _ in xrange(num_queries)]
18-
self.write(json.dumps(worlds))
18+
output = json.dumps(worlds)
19+
self.response()._headers["Content-Length"] = len(output)
20+
self.write(output)

frameworks/Python/historical/webware/app/Context/updates.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,6 @@ def defaultAction(self):
2121
world.randomNumber = rp()
2222
worlds.append(world.serialize())
2323
Database.DbSession.commit()
24-
self.write(json.dumps(worlds))
24+
output = json.dumps(worlds)
25+
self.response()._headers["Content-Length"] = len(output)
26+
self.write(output)

0 commit comments

Comments
 (0)