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

Add headers option on Http download strategy #89

Merged
merged 1 commit into from
Jul 11, 2019

Conversation

wilmarvh
Copy link
Contributor

@wilmarvh wilmarvh commented Jul 4, 2019

This pull request adds the ability to add an array of headers onto the Http download strategy.

It was created with the goal of being able to download a release binary hosted on Github which requires the Accept: application/octet-stream header. However it allows for any headers to be added onto the curl command to be being executed.

It is dependant on the following PR to be merged as well: CocoaPods/Core#557

An example of the usage looks as follows:

    s.source = {
        :http => "https://api.github.com/repos/my-organization/some-repository/releases/assets/123123", 
        type: :zip,
        :headers => [ "Accept: application/octet-stream" ]
    }

It also solves a bit of the frustration raised in CocoaPods/CocoaPods#5055

@wilmarvh wilmarvh changed the title Add headers option on RemoteFile/Http Add headers option on Http download strategy Jul 4, 2019
Copy link
Member

@amorde amorde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! Couple things then I think this should be good to go

lib/cocoapods-downloader/gem_version.rb Outdated Show resolved Hide resolved
lib/cocoapods-downloader/http.rb Show resolved Hide resolved
@dnkoutso
Copy link
Contributor

This would all properly serialize to JSON and back? Remember podspecs are published as JSON to the master specs repo.

@dnkoutso
Copy link
Contributor

If possible please squash to a single commit.

@wilmarvh
Copy link
Contributor Author

This would all properly serialize to JSON and back? Remember podspecs are published as JSON to the master specs repo.

Here's an example spec I've pushed to a private spec repo, I'm consuming through my fork of the downloader.

This is the source section of the podspec in question, using the :headers to enable downloading an asset linked to a Github release.

...
"source": {
    "http": "https://api.github.com/repos/xxx/xxx/releases/assets/xxx",
    "type": "zip",
    "headers": [
        "Accept: application/octet-stream"
    ]
},
...

@wilmarvh wilmarvh force-pushed the master branch 2 times, most recently from 01b50bf to 413bf4f Compare July 11, 2019 08:41
@wilmarvh
Copy link
Contributor Author

@dnkoutso Squashed, and added a changelog entry. I've also posted an example of a private podspec I'm using at the moment which contains headers, and how it would serialize to JSON.

@dnkoutso
Copy link
Contributor

dnkoutso commented Jul 11, 2019

Seems CI is failing, attempting to fix here #90

@dnkoutso
Copy link
Contributor

@wilmarvh I fixed master in #90 can you please rebase and we can land this! :D

- Add an option :headers key for the caller to provide custom headers
- Add HTTP headers spec
- Add changelog entry for :headers option

Co-authored-by: Wilmar van Heerden <github@wilmar.me>
Co-authored-by: Nico du Plessis <duplessis.nico@gmail.com>
@wilmarvh
Copy link
Contributor Author

@dnkoutso I did the thing, but one of the checks is still having a bad day :-/

@dnkoutso
Copy link
Contributor

rekicked it. Probably a flake

@dnkoutso dnkoutso merged commit bea449f into CocoaPods:master Jul 11, 2019
@dnkoutso
Copy link
Contributor

@wilmarvh yay! thanks!

@dnkoutso
Copy link
Contributor

I can ship cocoapods-downloader 1.3 but until we ship CocoaPods 1.8.x people wont be able to use it.

If you want to use this today then use https://bundler.io/ with a Gemfile and point to the master branch for cocoapods-downloader, cocoapods-core and cocoapods gems.

@wilmarvh
Copy link
Contributor Author

@dnkoutso Great, will do!

@wilmarvh
Copy link
Contributor Author

wilmarvh commented Oct 1, 2019

@dnkoutso Hi, a friendly check-in to find out where in the greater CocoaPods roadmap 1.3 of cocoapods-downloader is pegged for?

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

Successfully merging this pull request may close these issues.

None yet

4 participants