patx/mrhttp-asgi
Fix mime type for cached
Commit ffcf267 · Mark Reed · 2024-03-22T14:19:18-07:00
Comments
No comments yet.
Diff
diff --git a/src/mrhttp/internals/protocol.c b/src/mrhttp/internals/protocol.c
index a917f3f..feb856f 100644
--- a/src/mrhttp/internals/protocol.c
+++ b/src/mrhttp/internals/protocol.c
@@ -541,7 +541,9 @@ Protocol* Protocol_handle_request(Protocol* self, Request* request, Route* r) {
//}
// If we have cached bytes
if ( r->cached ) {
+ response_setMimeType(r->mtype);
if(!protocol_write_response(self, request, r->cached)) goto error;
+ return self;
}
if(!(result = protocol_callPageHandler(self, r->func, request)) ) {
diff --git a/tst.py b/tst.py
index c140b13..5cb5746 100755
--- a/tst.py
+++ b/tst.py
@@ -12,30 +12,19 @@ app.config["memcache"] = [ ("127.0.0.1", 11211) ]
#app.c = asyncmrq.Client()
#await app.c.connect(servers=[("127.0.0.1",7100)])
-#@app.route('/')
[email protected]('/',options=['cache'])
[email protected]('/',_type='text',options=['cache'])
+#@app.route('/',_type='text')
def index(r):
return "hello world"
[email protected]('/123456789123456789')
-async def long(r):
- return "long"
-
@app.route('/json')
def json(r):
return mrjson.dumps({'message': 'Hello, world!'})
[email protected]('/mrp',_type="mrp")
-def mrp(r):
- return mrpacker.pack("hello")
-
[email protected]('/{}/tst')
-def firstarg(r,a):
- return a
try:
- app.run(cores=4)
+ app.run(cores=1)
except Exception as e:
print("YAY",e)