Skip to content

Commit

Permalink
fix: Add fix for #83.
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Geer committed Dec 12, 2016
1 parent e21e6d6 commit 44b2090
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ sipi
*~
.idea/
SipiConfig.h
sipi.log*
sipi.log*.txt
/extsrcs/
/cmake-build-debug/

#
# Cmake things to be ignored
Expand Down
28 changes: 12 additions & 16 deletions config/sipi.init-knora-test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@ function pre_flight(prefix,identifier,cookie)
--
-- For Knora Sipi integration testing
-- Always the same test file is served
-- Make sure that this image file exists in config.imgroot
--
filepath = config.imgroot .. '/' .. prefix .. '/' .. 'Leaves.jpg'

print("serving test image " .. filepath)
filepath = config.imgroot .. '/' .. 'Leaves.jpg'

if prefix == "thumbs" then
-- always allow thumbnails
Expand Down Expand Up @@ -78,27 +77,24 @@ function pre_flight(prefix,identifier,cookie)
end

knora_url = 'http://' .. config.knora_path .. ':' .. config.knora_port .. '/v1/files/' .. identifier
print("knora_url: " .. knora_url)

result = server.http("GET", knora_url, knora_cookie_header, 5000)

-- check HTTP request was successful
if not result.success then
print("Request to Knora failed: " .. result.errmsg)
-- deny request
success, result = server.http("GET", knora_url, knora_cookie_header, 5000)
if not success then
server.log("server.http() failed: " .. result, server.loglevel.ERROR)
return 'deny'
end

if result.status_code ~= 200 then
print("Knora returned HTTP status code " .. ret.status)
print(result.body)
server.log("Knora returned HTTP status code " .. result.status_code)
server.log(result.body)
return 'deny'
end

response_json = server.json_to_table(result.body)

print("status: " .. response_json.status)
print("permission code: " .. response_json.permissionCode)
success, response_json = server.json_to_table(result.body)
if not success then
server.log("server.json_to_table() failed: " .. response_json, server.loglevel.ERROR)
return 'deny'
end

if response_json.status ~= 0 then
-- something went wrong with the request, Knora returned a non zero status
Expand Down
2 changes: 1 addition & 1 deletion config/sipi.knora-test-config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ sipi = {
-- expected to be urlencoded. Both will be decoded. That is, "/" will be recoignized and expanded
-- in the final path the image file!
--
imgroot = './images', -- directory for Knora Sipi integration testing
imgroot = './test_server/images', -- directory for Knora Sipi integration testing

--
-- If FALSE, the prefix is not used to build the path to the image files
Expand Down

0 comments on commit 44b2090

Please sign in to comment.