From 77010aaab5ce0375e5cc94cf74faa8101973d713 Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Fri, 24 May 2024 07:48:16 +0200 Subject: [PATCH 1/2] fix(request): explicitly specify line pattern Some luasocket versions do not handle the "*l" default well. By making it explicit, we can side step that failure. --- src/pegasus/request.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pegasus/request.lua b/src/pegasus/request.lua index b37f058..5253453 100644 --- a/src/pegasus/request.lua +++ b/src/pegasus/request.lua @@ -65,7 +65,7 @@ function Request:parseFirstLine() end local status, partial - self._firstLine, status, partial = self.client:receive() + self._firstLine, status, partial = self.client:receive("*l") if (self._firstLine == nil or status == 'timeout' or partial == '' or status == 'closed') then return @@ -140,7 +140,7 @@ function Request:headers() self:parseFirstLine() - local data = self.client:receive() + local data = self.client:receive("*l") local headers = setmetatable({},{ -- add metatable to do case-insensitive lookup __index = function(self, key) @@ -167,7 +167,7 @@ function Request:headers() end end - data = self.client:receive() + data = self.client:receive("*l") end self._headerParsed = true From 2f31a2848123bf562ef192df4878e84f7ca27dbc Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Fri, 24 May 2024 07:49:43 +0200 Subject: [PATCH 2/2] fix(example): json lib wasn't merged, so fall back to lua-cjson --- example/app.lua | 3 ++- example/copas.lua | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/example/app.lua b/example/app.lua index de46a35..4353b78 100644 --- a/example/app.lua +++ b/example/app.lua @@ -6,13 +6,14 @@ package.path = './src/?.lua;./src/?/init.lua;' .. package.path -- its examples. Copy the 'A' certificates into this example directory -- to make it work. -- Then uncomment the TLS plugin section below. +-- Additionally you need lua-cjson to be installed. local Pegasus = require 'pegasus' local Compress = require 'pegasus.plugins.compress' local Downloads = require 'pegasus.plugins.downloads' local Files = require 'pegasus.plugins.files' local Router = require 'pegasus.plugins.router' -local json = require 'pegasus.json' +local json = require 'cjson.safe' -- local TLS = require 'pegasus.plugins.tls' diff --git a/example/copas.lua b/example/copas.lua index e50537e..7836d50 100644 --- a/example/copas.lua +++ b/example/copas.lua @@ -8,6 +8,8 @@ package.path = "./src/?.lua;./src/?/init.lua;"..package.path -- to be installed, and you need to generate the test certificates from -- its examples. Copy the 'A' certificates into this example directory -- to make it work. +-- Additionally you need lua-cjson to be installed. + local Handler = require 'pegasus.handler' local copas = require('copas') local socket = require('socket') @@ -15,7 +17,7 @@ local Downloads = require 'pegasus.plugins.downloads' local Files = require 'pegasus.plugins.files' local Router = require 'pegasus.plugins.router' local Compress = require 'pegasus.plugins.compress' -local json = require 'pegasus.json' +local json = require 'cjson.safe' --- Creates a new server within the Copas scheduler.