Skip to content

Commit

Permalink
Merge pull request #145 from Tieske/fix/example
Browse files Browse the repository at this point in the history
fixes: luasocket default and json library
  • Loading branch information
EvandroLG authored May 30, 2024
2 parents 618476b + 2f31a28 commit d98eab5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion example/app.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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'


Expand Down
4 changes: 3 additions & 1 deletion example/copas.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ 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')
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.
Expand Down
6 changes: 3 additions & 3 deletions src/pegasus/request.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -167,7 +167,7 @@ function Request:headers()
end
end

data = self.client:receive()
data = self.client:receive("*l")
end

self._headerParsed = true
Expand Down

0 comments on commit d98eab5

Please sign in to comment.