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

Added user_agent argument to http methods #571

Merged
merged 5 commits into from
Jul 30, 2019
Merged

Added user_agent argument to http methods #571

merged 5 commits into from
Jul 30, 2019

Conversation

abbeycode
Copy link
Contributor

This way a caller, like the social media validator, can specify something different (Issue CocoaPods/CocoaPods#9049)

require 'rest'

resp = ::REST.head(url, 'User-Agent' => USER_AGENT)
user_agent ||= USER_AGENT
Copy link
Contributor

@dnkoutso dnkoutso Jul 29, 2019

Choose a reason for hiding this comment

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

can also set that as the default?

def self.perform_head_request(url, user_agent = USER_AGENT)
  # code
end

Copy link
Contributor Author

@abbeycode abbeycode Jul 30, 2019

Choose a reason for hiding this comment

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

I did at first, but realized this method is private to http.rb, so it becomes easier to pass nil at the call site(s) and then substitute it here (we could also expose the USER_AGENT default value as public, if you'd prefer).

…a caller, so the social media validator can specify something different (Issue CocoaPods/CocoaPods#9049)
@abbeycode abbeycode changed the base branch from 1-7-stable to master July 29, 2019 22:08
@dnkoutso dnkoutso added this to the 1.8 milestone Jul 29, 2019
CHANGELOG.md Outdated
@@ -45,6 +45,10 @@
[Eric Amorde](https://github.com/amorde)
[CocoaPods/CocoaPods#8785](https://github.com/CocoaPods/CocoaPods/issues/8785)

* Pass a non-browser user agent for social media validation
Copy link
Contributor

Choose a reason for hiding this comment

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

nit add two empty spaces at the end of this line for markdown formatting.

@@ -8,11 +8,11 @@ module HTTP
#
# @return [string]
#
def self.get_actual_url(url)
def self.get_actual_url(url, user_agent=nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit formatting is off here use bundle exec rubocop -a

@dnkoutso dnkoutso merged commit 9ae4051 into CocoaPods:master Jul 30, 2019
dnkoutso pushed a commit to CocoaPods/CocoaPods that referenced this pull request Jul 30, 2019
* Using change from CocoaPods/Core#571 to address Issue #9049

* Fixed bug, added changelog entry, fixed style violations

* Updated non-browser user agent to 'CocoaPods'

* Added PR CocoaPods/Core#571 as dependency until it's merged

* Updated Gemfile to point to master branch for Core
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.

2 participants