Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non existent / Non valid url crashes application on Windows #8

Open
lmfff opened this issue Dec 10, 2021 · 1 comment
Open

Non existent / Non valid url crashes application on Windows #8

lmfff opened this issue Dec 10, 2021 · 1 comment

Comments

@lmfff
Copy link

lmfff commented Dec 10, 2021

Using this workaround #7 (comment) for having REST-love work on Windows
I get this error with README SimpleExample 's when getting non existent / non valid url

Error: Thread error (Thread: 0x01c2cdc66900)

string:24: attempt to index local 'resp' (a boolean value)
stack traceback:
        string:24: in function '_WIN_REST'
        string:41: in main chunk
stack traceback:
        [string "boot.lua"]:777: in function <[string "boot.lua"]:773>
        [C]: in function 'error'
        [string "boot.lua"]:631: in function <[string "boot.lua"]:630>
        [string "boot.lua"]:604: in function <[string "boot.lua"]:594>
        [C]: in function 'xpcall'
@lmfff lmfff changed the title Non existent / Non valid crashes application on Windows Non existent / Non valid url crashes application on Windows Feb 19, 2022
@lmfff
Copy link
Author

lmfff commented Feb 19, 2022

This seems to be solved by editing the _WIN_REST function in rest-lib/win-rest.lua

This:

if(isHead) then
    return resp.raw_headers
else
    return resp.body
end

could be changed to this:

if resp then
    if(isHead) then
        return resp.raw_headers
    else
        return resp.body
    end
else
    return false
end

To avoid indexing "resp" when it is a boolean value (false). I also return false if resp is false.
This needs to be changed both in the function declaration and when creating the thread with this function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant