CocoaPods / cocoapods-downloader

A small library that provides downloaders for various source types (HTTP/SVN/Git/Mercurial)
MIT License
84 stars 72 forks source link

Add headers option on Http download strategy #89

Closed wilmarvh closed 5 years ago

wilmarvh commented 5 years ago

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: https://github.com/CocoaPods/Core/pull/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 https://github.com/CocoaPods/CocoaPods/issues/5055

dnkoutso commented 5 years ago

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

dnkoutso commented 5 years ago

If possible please squash to a single commit.

wilmarvh commented 5 years ago

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 commented 5 years ago

@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 commented 5 years ago

Seems CI is failing, attempting to fix here https://github.com/CocoaPods/cocoapods-downloader/pull/90

dnkoutso commented 5 years ago

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

wilmarvh commented 5 years ago

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

dnkoutso commented 5 years ago

rekicked it. Probably a flake

dnkoutso commented 5 years ago

@wilmarvh yay! thanks!

dnkoutso commented 5 years ago

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 commented 5 years ago

@dnkoutso Great, will do!

wilmarvh commented 5 years ago

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