summaryrefslogtreecommitdiff
path: root/lib/chef/http.rb
Commit message (Collapse)AuthorAgeFilesLines
* Use net/http and openssl instead of net/httpshttpsTim Smith2020-08-121-1/+2
| | | | | | | net/https just calls openssl and net/http. We can just do that ourselves and avoid the extra layer Signed-off-by: Tim Smith <tsmith@chef.io>
* clean up some weird looking conditionals in the retry logiclcg/fix-protocol-negotiationLamont Granquist2020-07-281-5/+5
| | | | Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Fix protocol negotiation for unversioned objectsLamont Granquist2020-07-281-8/+4
| | | | | | | | | We generally always do protocol negotiation on the get of the node object and the Chef::Node is an unversioned API, so we need to test that we backoff the API version to the highest version the server offers and then retry again. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Fix NoMethodError when server returns a 406.Pete Higgins2020-07-271-2/+5
| | | | Signed-off-by: Pete Higgins <pete@peterhiggins.org>
* Fix more typosTim Smith2020-06-231-1/+1
| | | | Signed-off-by: Tim Smith <tsmith@chef.io>
* Use .match? not =~ when match values aren't necessaryTim Smith2020-06-111-1/+1
| | | | | | Autocorrected from RuboCop Performance which is now smart enough to detect when you use the match and when you don't. Using match? does not create any objects so it's slightly faster and uses less memory. Signed-off-by: Tim Smith <tsmith@chef.io>
* Update to ssl_verify_mode on remote_filePhil Dibowitz2020-05-271-1/+15
| | | | | | | | | | | | | | | So it turns out the `berkshelf` has been passing it's entire `options` hash into `Chef::HTTP` this whole time, which, we should probably fix. However, one of those options was `:ssl_verify_mode`. We ignore entries in the `options` hash we don't recognize so this was fine, but suddenly we recognize it. But we expected it to be class, and they're passing in symbols. Whoops! This makes that all work and puts the symbol->class conversion inside of `Chef::HTTP`. Signed-off-by: Phil Dibowitz <phil@ipom.com>
* Merge pull request #9833 from jaymzh/remote_file_sslTim Smith2020-05-271-1/+2
|\ | | | | Add ssl_verify option for remote_file
| * Add ssl_verify option for remote_filePhil Dibowitz2020-05-181-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Different servers have different https requirements and enforcing the API policy on all `remote_file` resources isn't reasonable. The logic around the HTTP clients and policies in Chef is... complex. This approach seemed like the best one, but I'm open to others. By default here if the user specifies nothing, `remote_file`'s http clients will fall back to the API policy, otherwise, it'll use whatever the specify. This fixes #8897 Signed-off-by: Phil Dibowitz <phil@ipom.com>
* | Get lib/ free of spelling violations.Pete Higgins2020-05-181-1/+1
|/ | | | Signed-off-by: Pete Higgins <pete@peterhiggins.org>
* Remove copyright dateslcg/remove-copyright-datesLamont Granquist2020-04-131-1/+1
| | | | | | | | Legally incredibly dubious, particularly since we don't follow it strictly as policy, and we have git history instead, which does it right. This is just a waste of time and a cargo cult. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Add chef-utils gem with various recipe DSL helpersLamont Granquist2019-11-081-1/+1
| | | | | | | | | | | | | This is the implementation of [RFC-087](https://github.com/chef-boneyard/chef-rfc/blob/master/rfc087-distro-sugar-helpers.md) although some of the specifics have been iterated on and changed. The documentation will be in the [README.md](https://github.com/chef/chef/tree/master/chef-utils/README.md) once this is merged. While this PR mostly moves chef-sugar utilities into core-chef via this chef-utils gem, the scope of the chef-utils gem should be considered larger than just that. As an example this PR moves the Mash class into this gem for reuse in ohai as well. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Style/SymbolProcLamont Granquist2019-07-051-1/+1
| | | | | | enforce pretzels. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Style/ClassCheckLamont Granquist2019-07-051-15/+15
| | | | | | convert kind_of? to is_a? Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Style/RegexpLiteralLamont Granquist2019-07-051-1/+1
| | | | | | | given how many regexps we have with /'s in the match this seems like a very good one. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Style/SymbolArrayLamont Granquist2019-07-021-1/+1
| | | | | | start enforcing using %i{} instead of arrays of symbols Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* fix Layout/EmptyLineAfterGuardClauseLamont Granquist2019-07-021-0/+5
| | | | | | | i like this one, gives visual priority to returns or raises that are buried in the middle of things. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* This hits the ones that are most frequently required.lcg/require-idempotencyLamont Granquist2019-05-201-2/+2
| | | | | | | | | Stops the kernel from scanning through all the activated gems every time in order to resolve names into pathnames. See rubygems/rubygems#2762 Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Convert require to require_relativeLamont Granquist2019-05-081-6/+6
| | | | | | | This gives a speed boost since rubygems does not have to scan through every gem in the gemset in order to find the file. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* change HTTPServerException to HTTPClientException for ruby 2.6Lamont Granquist2019-01-031-3/+3
| | | | | | includes backcompat for 2.5 Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Fix a yard syntax errorTim Smith2018-08-231-1/+1
| | | | Signed-off-by: Tim Smith <tsmith@chef.io>
* Merge pull request #7006 from bugok/http_auth_header2Lamont Granquist2018-04-021-1/+13
|\ | | | | Stripping Authorization header upon redirects (second try)
| * Stripping 'Authorization' header upon redirects (second try)Noam Lerner2018-03-211-1/+13
| | | | | | | | Signed-off-by: Noam Lerner <noamler@fb.com>
* | mechanical conversion of most debug log statements to traceThom May2018-03-261-9/+9
|/ | | | Signed-off-by: Thom May <thom@chef.io>
* Revert "Stripping out Authorization header on redirect to a different host"Tim Smith2018-03-161-3/+1
| | | | This reverts commit 08b31872bf4094bbef474cae6de6c90fb4245a99.
* Stripping out Authorization header on redirect to a different hostNoam Lerner2018-03-141-1/+3
| | | | Signed-off-by: Noam Lerner <noamler@fb.com>
* speed up http func testslcg/speed-up-http-func-testsLamont Granquist2018-01-231-1/+1
| | | | | | | | | | For the truncated downloads the tiny server needs to hit its RequestTimeout in order to terminate the truncated request, so that is set to 1 second. Then also drop down the retries and the rest_timeout on the client side (but keep the rest_timeout to 2 to keep it above the tiny_server timeout) Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* allow injecting tempfiles into Chef::HTTPlcg/chef-http-inject-tempfileLamont Granquist2017-12-191-10/+10
| | | | | | | | | use this to inject the tempfile from Chef::FileContentManagement::Tempfile closes #2401 Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* remove retry delays on protocol negotiationlcg/versioned-postsLamont Granquist2017-07-201-3/+0
| | | | Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* fix retries on JSON POST requests when negotiating protocol versionLamont Granquist2017-07-201-7/+9
| | | | | | | | | | | | | | | | | | | | | | on the first pass through the JSON middleware it encodes the body. if there's a retry, it re-encodes the body as a string with all its metacharacters escaped. this is a particular issue when doing a first request that is a POST that requires negotiating the API version. when doing a GET it isn't a problem because there's no body payload -- but a POST or a PUT which requires a retry will get garbled and will cause a 500. this happens on hosted right now if trying to POST with a v2 API since hosted is only v1, so there's a retry to downgrade. i also made the same kind of changes to the streaming download requests, but since they're GETs its unclear to me if there was any impact there -- but middleware could have been double-mangling headers on a retry. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Retry API requests if using an unsupported versiontm/retryable_apiThom May2017-03-291-0/+39
| | | | Signed-off-by: Thom May <thom@chef.io>
* Fix a few bad copyrightsTim Smith2016-10-201-1/+1
| | | | | | I think this happened when we merged the Opscode and Chef copyrights Signed-off-by: Tim Smith <tsmith@chef.io>
* Rebuild HTTP headers on each retried requestShane da Silva2016-10-151-3/+2
| | | | | | | | | | | | | | Depending on how you configure your Chef client, it's possible that a later retry would have an authentication timestamp header (`X-OPS-TIMESTAMP`) that was more than 900 seconds old. Since the Chef server treats timestamps older than this threshold as unauthorized requests, you would potentially get seemingly spurious "401 Unauthorized" responses from the server. A solution is to generate the headers on each retry so that we have a new authentication timestamp for each retried request. Signed-off-by: Shane da Silva <shane@dasilva.io>
* rearrange private/public add @api privateLamont Granquist2016-08-181-11/+25
| | | | Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* add an @api private commentLamont Granquist2016-08-181-0/+1
| | | | Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* stray Lint/UselessAccessModifierlcg/more-more-copsLamont Granquist2016-08-171-2/+0
| | | | Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* fix Style/BlockDelimiters, Style/MultilineBlockLayout and 0.42.0 engine upgradeLamont Granquist2016-08-171-2/+0
| | | | Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* Update to latest chefstyleJohn Keiser2016-08-171-2/+0
|
* test Chef::HTTP and tweak cacheLamont Granquist2016-08-111-2/+6
| | | | | | this is mildly awful, but works around the String-vs-URI crap Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
* cache correctlyLamont Granquist2016-08-091-3/+2
|
* make keepalives entirely optionalLamont Granquist2016-08-091-21/+32
| | | | turn on only for the cookbook synchronizer
* per-host/port cache of BasicClientLamont Granquist2016-08-091-1/+5
|
* memoize the BasicClientLamont Granquist2016-08-091-13/+16
|
* Remove deprecated Thread.exclusive around require call.Marin Jankovski2016-06-291-5/+5
|
* Merge pull request #4658 from chef/tm/remote_file_download_progress11.9Thom May2016-03-151-1/+31
|\ | | | | Remote file download progress
| * Enable progress output to be configuredtm/remote_file_download_progressThom May2016-03-041-6/+2
| | | | | | | | Add tests around progress output and tidy up
| * Merge branch 'remote-file-download-progress' of ↵Thom May2016-03-031-1/+35
| |\ | | | | | | | | | https://github.com/brandocorp/chef into tm/remote_file_download_progress
| | * fix broken specsBrandon Raabe2015-03-211-1/+1
| | |
| | * new doc formatter event, remove progress barBrandon Raabe2015-03-201-77/+32
| | |
| | * pass resource as an option to allow access to resource eventsBrandon Raabe2015-03-181-8/+20
| | |