Commit Graph
25 Commits
Author SHA1 Message Date
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 597bf7ade9 Log proper headers in trace logs 2017-03-05 11:19:01 -08: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 515197a903 Don't try and decode an empty body 2016-07-28 11:26:55 +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
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
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
Darryl RingandHonza Král a9b8f86547 Log response body for failed requests
Addresses #346
2016-02-01 09:32:43 +01: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 72d24906d7 Clarifying connection parameters.
Fixes #171 Thanks DavidAwad!
2014-12-30 17:21:22 +01:00
j0hnsmithandHonza Král 482f166c1a set propagate=False on elasticsearch.trace only if logger not already configured 2014-12-09 15:31:19 +01:00
Honza Král cb68308abf Body in the logs should be debug-level
Fixes #119, thanks traxair!
2014-09-10 16:24:44 +02:00
Andrew SnareandHonza Král 4d37a54c95 Use simplejson if present instead of the stdlib json module.
The simplejson parser drop-in compatible with the builtin python JSON
parser, but much faster. In particular, this makes operations like
reindexing quicker.
2014-06-25 10:21:36 +02:00
Honza Král f10d7f2da2 Body is always sent as utf-8 bytes, reflect it in tests
Thanks johbo for the report!
2014-05-09 18:11:50 +02:00
Honza Král c2611e92eb Set timeout properly for Requests and Thrift connections 2014-01-23 08:48:42 +01:00
Honza Král be9acfad90 Make sure we handle quotes correctly in the trace logger 2013-12-11 14:41:42 +01:00
Honza Král 19f9eaab95 Make sure bulk requests are logged correctly 2013-12-03 02:04:11 +01:00
Honza Král c5c98dcaac Add logging of body as INFO on connection error 2013-12-03 01:55:32 +01:00
Honza Král b8b9f67092 Logging fixes 2013-11-03 22:39:03 +01:00
Honza Kral e91ed68bd0 Split individual connection classes 2013-08-25 16:39:56 +02:00