Commit 574da2d1 authored by François Perrad's avatar François Perrad
parent 048a8679
......@@ -6,6 +6,11 @@ Revision history for lua-Spore
- use WADL document as Spore specification
LIMITATION: cross-references are not supported
- add wadl2spore utility
INCOMPATIBILITY (see http://github.com/fperrad/lua-Spore/issues/12)
cli:meth{ payload = '@filename' } is no longer supported,
and could be rewritten like this :
local slurp = require 'Spore.Protocols'.slurp
cli:meth{ payload = slurp'filename' }
0.2.1 Sun Sep 16 11:30:00 2012
- add middleware Auth.DataPublica
......
......@@ -15,7 +15,6 @@ local crypto = require 'crypto'
local digest = crypto.digest or crypto.evp.digest
local hmac = crypto.hmac
local request = require 'Spore.Protocols'.request
local slurp = require 'Spore.Protocols'.slurp
require 'Spore'.early_validate = false
_ENV = nil
......@@ -86,10 +85,6 @@ function m:call (req)
local payload = spore.payload
if payload then
if payload:sub(1, 1) == '@' then
local fname = payload:sub(2)
payload = slurp(fname)
end
req.headers['content-length'] = payload:len()
req.headers['content-type'] = req.headers['content-type'] or 'application/x-www-form-urlencoded'
if spore.headers and spore.headers['Content-MD5'] == 'AWS' then
......
......@@ -109,10 +109,6 @@ local function request (req)
local payload = spore.payload
if payload then
if payload:sub(1, 1) == '@' then
local fname = payload:sub(2)
payload = slurp(fname)
end
req.source = ltn12.source.string(payload)
req.headers['content-length'] = payload:len()
req.headers['content-type'] = req.headers['content-type'] or 'application/x-www-form-urlencoded'
......
......@@ -30,7 +30,7 @@ is( env.spore.params.border, 'border' )
error_like( function () client:get_user_info{} end,
"payload is required for method get_user_info" )
error_like( function () client:get_user_info{ payload = '@file' } end,
error_like( function () client:get_user_info{ payload = 'opaque data' } end,
"user is required for method get_user_info" )
local res = client:get_user_info{ user = 'joe', payload = 'OPAQUE' }
......@@ -41,7 +41,7 @@ local res = client:get_info{ user = 'joe' }
local env = res.request.env
is( env.spore.params.user, 'joe' )
error_like( function () client:get_info{ payload = '@file' } end,
error_like( function () client:get_info{ payload = 'opaque data' } end,
"payload is not expected for method get_info" )
error_like( function () client:get_info{ mode = 'raw' } end,
......@@ -53,7 +53,7 @@ lives_ok( function () client:get_info{ mode = 'raw' } end )
Spore.errors = io.tmpfile()
status = 404
r, ex = pcall( function ()
local res = client:get_user_info{ payload = '@file', user = 'john' }
local res = client:get_user_info{ payload = 'opaque data', user = 'john' }
end)
is( r, false, "exception" )
is( tostring(ex), "404 not expected", "404 not expected" )
......
......@@ -11,11 +11,11 @@ require 'Spore.Protocols'.request = function (req) return response end -- mock
local client = Spore.new_from_spec './test/api.json'
local res = client:get_user_info{ payload = '@file', user = 'john' }
local res = client:get_user_info{ payload = 'opaque data', user = 'john' }
is( res, response, "without middleware" )
client:enable 'Format.JSON'
local res = client:get_user_info{ payload = '@file', user = 'john' }
local res = client:get_user_info{ payload = 'opaque data', user = 'john' }
is( res, response, "with middleware" )
client:enable 'UserAgent'
......
......@@ -31,7 +31,7 @@ local r = client:get_info{ user = 'Joe', border = 1 }
is( r.request.env.spore.params.user, 'Joe' )
is( r.request.env.spore.params.border, 1 )
local r = client:get_user_info{ payload = '@file' }
local r = client:get_user_info{ payload = 'opaque data' }
is( r.request.env.spore.params.user, 'John' )
is( r.request.env.spore.params.border, 0 )
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment