-
Notifications
You must be signed in to change notification settings - Fork 594
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
hs.http must follow redirects #1889 #3279
Conversation
pdckxd
commented
Aug 22, 2022
- new parameter "enableRedirect" for hs.http.doAsyncRequest
- add 5 tests to test this change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pull request does not contain a valid label. Please add one of the following labels: pr-fix, pr-change, pr-feature, pr-maintenance
0e7a1e5
to
8cd292e
Compare
extensions/http/libhttp.m
Outdated
|
||
NSString* cachePolicy = nil; | ||
if (lua_type(L, 6) == LUA_TSTRING) { | ||
cachePolicy = [skin toNSObjectAtIndex:6]; | ||
} | ||
|
||
bool enableRedirect = true; | ||
if (lua_type(L, 7) == LUA_TBOOLEAN) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way you have this now, to specify the enableRedirect option, the cachePolicy becomes non-optional. We are very inconsistent about this sort of thing across the codebase, but FWIW it's pretty easy to handle - add LS_TBOOLEAN as an option for the 6th argument and here check the lua_type()
of position 6 first, to see if the boolean is there.
This scales very poorly with lots of additional optional arguments, but for the first one it's not too bad.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sense. Let me revise. Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from optional string & boolean, I am thinking about if we can also support optional table for 6th parameter. Users can pass {cachePolicy= "xxx", enableRedirect=false} if they want to use both 2 parameters. What's your opinion? @cmsj
1. new optional parameter "enableRedirect" for hs.http.doAsyncRequest 2. add 4 tests to test this change pr-feature
The optional table idea is what we should have done, but for now we're stuck with the idioms we have. |