-
-
Notifications
You must be signed in to change notification settings - Fork 10.7k
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
add new CurlPostDownloadStrategy #3422
add new CurlPostDownloadStrategy #3422
Conversation
It would be neat to have the possibility of POSTing forms that then redirect to the correct url. A lot of vendors appear to only offer this possibility. This patch helps address that problem. |
Thanks for this! I'll review it tomorrow. Do you have an example Cask where this would be used? |
Yes I do. Would you like me to push it here, or to a new branch and separate PR? |
Sorry, I rewrote my branch to squash a separate test commit into the main one. If you've pulled from my branch to test locally, please pull again cleanly. |
Please see #3423 for use case. |
You added tests? Great! Yes, it is better to keep the Cask in a separate PR, so that users don't pull in a broken Cask via |
The code looks great. I'm trying to figure out why Homebrew implements this in much fewer lines of code (https://github.com/Homebrew/homebrew/blob/master/Library/Homebrew/download_strategy.rb#L264). However, there don't seem to be any Homebrew Formulae which actually use I assume the Also, def post_args
@post_args ||= if cask_url.data
# sort_by is for predictability between Ruby versions
cask_url.data.sort_by{ |key, value| key.to_s }.map do |key, value|
['-d', "#{CGI.escape(key.to_s)}=#{CGI.escape(value.to_s)}"]
end
end
end Elsewhere, we would say, for example, args.concat(post_args) if nil These are just points for discussion; please don't think that addressing every item is a requirement for inclusion of this very useful code. |
I did notice Homebrew's own I simplified
Another thing: I had to change the relevant test, because |
- lib/cask/url.rb: initialize(): add new `:data` attribute to hold post parameters - lib/cask/download.rb: perform(): dispatch to new class based on `:using => :post` - lib/cask/download_strategy.rb: Cask::CurlPostDownloadStrategy: extend curl_args with x-www-form-urlencoded data - doc/CASK_LANGUAGE_REFERENCE.md: HTTP URLs: document new strategy - test/cask/test_download_strategy.rb: Cask::CurlPostDownloadStrategy: test new strategy
Yes, your interface is far better than hacking the URL string. I'm weak on the testing infrastructure in Ruby, will study your changes/notes with interest. Will check out this branch again tomorrow and run the tests. In my view, this is ready to merge. But let's leave the PR open for a few days in case anyone cares to add to the discussion. |
add new CurlPostDownloadStrategy
Great! Thanks for your efforts. I will have a look at those PRs later tonight. |
:data
attribute to hold post parameters:using => :post
extend curl_args with x-www-form-urlencoded data