Commit Graph
104 Commits
Author SHA1 Message Date
Honza Král a023bddb4d Use provided request headers in urllib3
outside. However, `Urllib3HttpConnection` did not use these headers but
only its default ones.

With this commit, `Urllib3HttpConnection` will either use the default
ones or merge the default headers with the provided ones if there are
any.

Relates #618
2018-01-01 15:42:46 +01:00
Nick Lang 456e598c5b moving import 2017-12-28 13:09:16 -07:00
Nick Lang bf1d64e88d Updates to SSL Context changes,
Bug with OSX made breaking changes to the way certifi was being imported
and used.

Unable to reproduce with Linux.

Found improper logic. Fixed now.
Also changing removing the flag for checking `verify_certs` as
it is `True` by default. Don't want to make users flag that as
`False` just to make things work.

A connection to an SSL instance should be:

    es = Elasticsearch("https://host:port", http_auth=(user,pass))

* If using Elastic Cloud or some other publicly recognized certificate
  that certifi can recognize.
2017-12-27 20:26:23 -07:00
Nick LangandHonza Král 37490e223f When _just_ using an SSL context we don't want breaking behavior (#673)
Also don't want to break backwards compat. So when chcking for depreicated values ignore
the check on verify_certs. Since it's True. the verify certs will be default true
in the ssl_context. And can be turned off in the SSL context when using it.
2017-11-28 22:01:20 +01:00
Honza Král f639f9b28e Apply cafile defaults before checking for emptiness
Fixes #669
2017-11-14 19:20:15 +01:00
Nick LangandGitHub 5c537deca4 Merge pull request #635 from fxdgear/nick/ssl_context
Nick/ssl context
2017-10-06 11:35:23 -06:00
Nick Lang 7339a272b5 Add SSL context for versions of Python that support SSL Context.
Instead of passing parameters manually, you can construct an SSL
context. This allows for greater flexibility in using self signed certs.
2017-10-06 11:27:15 -06:00
Joshua Carp 3045516738 Clean up custom headers. 2017-10-04 16:07:55 -04:00
Joshua Carp 073db90ae8 Set application/x-ndjson content type on bulk requests.
Resolves #609
2017-10-04 16:07:55 -04:00
Tyler James HardenandHonza Král cd769b98a5 Additional fixes for UTF-8 surrogate escapes (#629)
* Fixes non UTF-8 surrogateescapes 

Surrogate escapes in Unicode (non UTF-8 encoding) will be properly escaped with backslashes when encountered, versus breaking the transport layer.

* Removes erroneous bytes decode and reraises

Fixes to re-raise exceptions with different reasons
Removes erroneous bytes decode where bytes are desired

* Adds test for surrogate escapes in body

Tests that a surrogate escape sequence is properly escaped
with backslashes to produce valid UTF-8.

* Use proper byte sequence for surrogate

* Use if/else versus pass

* Proper Unicode surrogate escape

Use a Unicode Surrogate that properly escapes in both Python2 and Python3

* Passing test once surrogatepass is used

Updating test to pass once surrogatepass is used

* Use surrogatepass instead of backslashreplace

This replicates behavior between Python 2 and Python 3

* Fixes whitespace

* Simplifies with no exception block

Since `surrogatepass` will only ever explicitly occur when there are surrogate bytes encountered, there is no need to let the error throw and catch it, also uses single-quotes for consistency.

* Fixes Unicode Surrogate Escapes in request logging

This is the same fix as accepted for ElasticSearch requests, except applied to the request logging mechanisms.
2017-08-15 15:41:32 +01:00
Honza Král d336c571b9 [WIP] remove scheme checking 2017-05-15 22:01:54 +02:00
Honza Král c318f7fa63 Make sure environment settings are merged in for requests
Fixes #557
2017-04-17 21:59:03 +02:00
Honza Král 597bf7ade9 Log proper headers in trace logs 2017-03-05 11:19:01 -08:00
Honza Král d862c8a799 Add content-type default headers with application/json 2017-02-08 20:50:50 +01:00
Honza Král 8107bbcf93 update headers in lowercase to allow overriding of auth headers 2017-01-03 15:07:28 +01:00
Honza Král b9ba12977f Refactored connection error handling 2016-12-15 16:46:05 +11:00
Javier AguirreandHonza Král 8e69b98844 Fix UnboundLocalError response (#476) (#481) 2016-12-06 18:10:44 +01:00
Honza Král 8b96556769 Change the trace logger to also include failed requests 2016-10-19 15:28:31 +02:00
Honza Král bf561fb856 Fix maxsize parameter description.
Fixes #414 Thanks theanti9!
2016-10-17 17:27:33 +02:00
Honza Král 8314f7b25c Set verify_certs default to True
If certifi is installed use it as default for ca_certs value
Closes #403
2016-10-17 14:16:56 +02:00
Honza Král 515197a903 Don't try and decode an empty body 2016-07-28 11:26:55 +02:00
Honza Král 311ac7c814 Allow specifying custom http headers 2016-07-12 18:13:48 +02:00
Honza Král a53efe1705 Respect the transport_schema when constructing host 2016-06-28 16:44:58 +02:00
Juri HudolejevandHonza Král 9f2608c469 Fix HTTPS URL support (#411)
* Fix scheme for HTTPS URLs

For URLs like https://example.org scheme is currently set to 'http'.

* Revert "Fix scheme for HTTPS URLs"

This reverts commit 5dcee5bd2a8ce4453b495e637b283e7558718262.

* Fix HTTPS URL support
2016-06-20 13:08:36 +02:00
Adam ChainzandHonza Král 40db4b6228 Convert readthedocs links for their .org -> .io migration for hosted projects (#413)
As per [their blog post of the 27th April](https://blog.readthedocs.com/securing-subdomains/) ‘Securing subdomains’:

> Starting today, Read the Docs will start hosting projects from subdomains on the domain readthedocs.io, instead of on readthedocs.org. This change addresses some security concerns around site cookies while hosting user generated data on the same domain as our dashboard.
2016-06-08 14:41:44 +02:00
Honza Král b83df5e832 hasHandlers is only valid since python 3.2 2016-04-27 17:37:35 +02:00
Honza Král 418b93bfec Do not warn on 404s when using HEAD method
Fixes #396
2016-04-27 13:21:47 +02:00
Honza Král cc14efd5df Only do tracer logging if there are handlers
Fixes #391, thanks cp2587 for the report!
2016-04-09 18:12:33 +02:00
Honza Král c51b8fdeef Refactored sniff_hosts for easier implementation of AsyncTransport 2016-03-14 22:23:04 +01:00
Grégory StarckandHonza Král 879de7549e Fixed a bare except
AFAIK the only exception which can occur here is one that the json.loads(..) could raise. So (TypeError or) ValueError.

So except on that. and also log a warning in such case.

bare excepts are 99.99% of the time simply bad/wrong. It's the case here.
2016-03-04 15:21:41 +01:00
Will McGinnis b0d3de0ada requested changes. 2016-03-03 19:50:17 -05:00
Will McGinnis 8a18e4c743 added close methods to everything below transport 2016-03-03 19:31:31 -05:00
Honza Král 5dfd6985e5 Only pass in cert to request.session if client_cert specified 2016-02-29 22:39:58 +01:00
Rich MegginsonandHonza Král fe6e9a7f5c Urllib3HttpConnection should have separate client_cert and client_key arguments #344
https://github.com/elastic/elasticsearch-py/issues/344
Add a client_key parameter to complement the client_cert parameter.  If
client_key is used, it is assumed that client_cert will contain only the
certificate, not the combined cert and key in a single file.

Closes #344
2016-02-29 22:35:40 +01:00
Darryl RingandHonza Král a9b8f86547 Log response body for failed requests
Addresses #346
2016-02-01 09:32:43 +01:00
Honza Král efc1156bd5 add description of the basic params for Urllib3HttpConnection 2015-11-19 11:10:07 -06:00
Chris EarleandHonza Král f3315dc98d Adding assert_hostname and assert_fingerprint parameters to Urllib3HttpConnection 2015-11-10 16:15:56 +09:00
Honza Král 6f7a56964c Removing ThriftConnection and MemcachedConnection 2015-10-07 17:47:05 +02:00
Honza Král 72f661f953 Added deprecation infor for thrift connection class 2015-07-06 18:13:02 +02:00
Honza Král 845f8cd6f5 Adding ssl_version parameter to Urllib3HttpConnection
Fixes #246
2015-07-06 18:09:44 +02:00
Honza Král d328998b36 Add keep_alive headers by default to Urllib3HttpConnection 2015-06-22 20:39:58 +02:00
Jim Kelly 032a1aa799 Fixes issue introduced in 482f166 where the tracer spams when
unconfigured.

In the aforementioned commit, the existing behavior was changed,
I believe in advertantly, to set propagate to False if the
trace logger already has been configured. This seems to be the
opposite of the internet, and this change restores what appears
to have been the intent, and silences the tracer unless
it has been configured, in which case it will propagate.
2015-04-28 22:32:57 +02:00
Honza Král 42b4cfd3aa Get ready for the structured exceptions coming in es 2.0 2015-04-27 20:40:55 +02:00
Honza Král 453fe64987 Add docs for the http_auth parameter of RequestsHttpConnection 2015-03-27 10:46:30 +01:00
Honza Král aa2d4f079c Adding tests for advanced auth options for requests 2015-03-26 14:17:10 +01:00
Georges Toth fc98b5d352 Modify test for http_auth to allow for passing custom authentication methods as well 2015-03-26 12:39:09 +01:00
Russell Savage 4c24468168 updating doc links to elastic.co
reverting bucket link to elasticsearch.org

updating test cases to use elastic.co

updating pylibmc version
2015-03-23 15:56:32 -07:00
Sven Wästlund 3616f7208a socket.error is now caught in perform_request aswell.
Fixes #205
2015-03-11 16:17:10 +01:00
Honza Král b92d591026 Make method utf-8 for urllib3
fixes #201
2015-02-26 14:14:33 -08:00
Honza Král 271fc4d232 Warn when people using insecure options. 2015-01-29 23:46:01 +01:00