42 Commits

Author SHA1 Message Date
HoneyryderChuck
e98c72e3c5 response buffer: increase coverage, fix buffer dup when tempfile, simplify == as buffer always responds to read 2025-09-04 09:37:09 +01:00
sarna
4bf07e75ac Accept more MIME types with json suffix
Fixes #326 #327
2024-12-03 08:50:07 +00:00
HoneyryderChuck
8b2ee0b466 remove form, json, ,xml and body from the Options class
Options become a bunch of session and connection level parameters, and requests do not need to maintain a separate Options object when they contain a body anymore, instead, objects is shared with the session, while request-only parameters get passed downwards to the request and its body. This reduces allocations of Options, currently the heaviest object to manage.
2024-06-11 18:23:45 +01:00
HoneyryderChuck
dcbd2f81e3 change internal buffer fetch using ivar getter 2024-06-11 18:21:54 +01:00
HoneyryderChuck
994049da8c fix decoding issue in test by not allowing to reuse same response object
buffering more chunks after decoding response payload leads to dubious results in ruby 3.3, and is, from a usability perspective, not even something httpx should allow
2024-01-13 15:39:10 +00:00
Brian Koh
b8f0d0fbcd Allow pattern matching for Ruby 2.7 2023-11-22 23:14:50 +08:00
HoneyryderChuck
0d58408c58 compression plugins for gzip and deflate supported by default
most of the code was moved to the transcoder layer.

The `compression_threshold_size` option has been removed.

The `:compression/brotli` plugin becomes only ´:brotli`, and depends on
the new transcoding APIs.

options to skip compression and decompression were added.
2023-09-20 17:57:41 +01:00
HoneyryderChuck
f066bc534f fixed Response::Body#read test, which didn't really test for equality, and was therefore broken 2023-06-08 23:24:34 +01:00
HoneyryderChuck
bd233c5303 effort to increase coverage of tests 2023-04-28 23:57:25 +01:00
HoneyryderChuck
bbf257477b Removing HTTPX::Registry and its usage internally
These internnal registries were a bit magical to use, difficult to
debug, not thread-safe, and overall a nuisance when it came to type
checking. So long.
2023-04-27 22:49:20 +01:00
HoneyryderChuck
092e594a4b Request.verb is now an upcased string (ex: "GET")
The reference for a request verb is now the string which is used
everywhere else, instead of the symbol corresponding to it. This was an
artifact from the import from httprb, and there is no advantage in it,
since these strings are frozen in most use cases, and the
transformations from symbol to strings being performed everywhere are
prooof that keeping the atom isn't really bringing any benefit.
2023-04-17 16:54:31 +03:00
HoneyryderChuck
db939b56d2 Adding HTTPX::Response::Body#filename
This returns the filename advertised in the content-disposition header.
It reuses the same logic which existed for parsing multipart responses,
which itself was based on `rack`'s.
2022-12-29 01:09:14 +00:00
HoneyryderChuck
c70209db4b added xml transcoder
capabilities to encod/decode xml, expects nokogiri.
2022-08-13 15:42:46 +01:00
HoneyryderChuck
82a3657153 disabling pattern matching tests for truffleruby 2022-03-21 23:43:38 +00:00
HoneyryderChuck
f768cf7a0e Improving API compatibility and error checking in responses
* `Response#error`, which, coupled with `ErrorResponse#error`, allows
  for `if response.error` kind of conditional;
* `Response#raise_for_status` now returns the response when no error is
  raise (for method chaining);

Closes #153
2021-09-20 13:02:20 +01:00
ojab
6f3b11eb16
Fixup decoders content type checks 2021-09-10 15:53:38 +00:00
HoneyryderChuck
c95e926886 auto-corrected the easy ones first 2021-09-03 12:24:18 +01:00
HoneyryderChuck
f2d3c1f09b added Response#form (supports only x-www-urlencoded for now) 2021-08-09 15:54:25 +01:00
HoneyryderChuck
e5a120111c added tests for json and form (also multipart) decoders 2021-08-09 15:54:24 +01:00
HoneyryderChuck
e43d5eddcd making body comparison less wasteful, while keeping existing poinnters after call to to_s 2021-07-24 04:00:19 +01:00
HoneyryderChuck
0f1d8cb271 make Response#to_s non-destructive, and keep the body around
for most cases, this didn't make sense, i.e. response bodies were so
    small, and the user is fine with keeping it all in mem, whereas
    clearing the string is more confusing. And it breaks pattern
    matching when matching body multiple times.
2021-07-24 04:00:19 +01:00
HoneyryderChuck
34c6562469 enabling pattern matching only for 3.0.0 2021-06-17 18:09:00 +01:00
HoneyryderChuck
c7704b6e15 disable pattern matching tests for truffleruby 2021-06-12 13:57:54 +01:00
HoneyryderChuck
f7ecc145e6 added pattern-matching support for responses 2021-06-12 02:44:16 +01:00
HoneyryderChuck
12d4885136 response body now holds the full options from the request 2021-03-05 19:04:09 +00:00
HoneyryderChuck
b6c94f1702 added test for unsupported charset in response 2021-02-18 10:43:48 +00:00
HoneyryderChuck
7e26c86dc1 really closing a response (won't buffer stuff anymore after being closed) 2020-11-22 15:55:44 +00:00
HoneyryderChuck
41ca6fadbb added test for copy_to; also, fixed it (rewind before copy) 2020-03-15 19:59:39 +00:00
HoneyryderChuck
aebadc8bc9 testing Response#read 2020-03-10 18:58:31 +00:00
HoneyryderChuck
6005165271 testing status reach of HTTPError 2019-12-31 01:56:21 +00:00
HoneyryderChuck
a421fb121b minimal changes to accomodate new kwargs syntax 2019-12-30 02:24:04 +00:00
HoneyryderChuck
e36c6347bf rubocop indications 2018-03-23 14:48:10 +00:00
HoneyryderChuck
67eb755a3b added Response#raise_for_status, which raises an exception if the http code is an error code; it also duck-types the error response, which will raise its exception 2018-03-23 10:53:16 +00:00
HoneyryderChuck
2b1ab8b6b6 rubocop auto-corrections according to some basic rules for now 2018-01-28 22:33:41 +00:00
HoneyryderChuck
57aa3b5159 testing the client yield feature and the response body buffer transitions 2018-01-28 21:59:08 +00:00
HoneyryderChuck
284bb06663 added versioning to response (important to test h2c, but also to ensure which 1.x is responding) 2018-01-06 19:23:39 +00:00
HoneyryderChuck
957fc46bcf response: do not alias #write to #<<, makes it hard to extend; #each now yields predictable-size chunks, instead of deferring to buffer#each, which can do whatever 2017-12-22 13:14:33 +02:00
HoneyryderChuck
15a5ffffdd allow to pass a custom body class, which only needs to implement the constructor signature and #<< 2017-12-11 13:10:58 +00:00
HoneyryderChuck
40a73f5a7b made body threshold size (the max buffered size after which the response body is buffered to disk) a top-level option 2017-12-11 12:43:05 +00:00
HoneyryderChuck
d8eb3bbe5f went back from returning partial responses, and only expose fully buffered responses to the user; the main issue being, the main API favours closing the connection after requests, and this makes the whole handling of partial responses confusing and error prone; this way, one can buffer the body, even to the filesystem, and maybe make this tunable in the future 2017-12-08 19:01:44 +00:00
HoneyryderChuck
ee59c71274 allow to return early responses just with headers; added a bufferable body, which means, when body is requests, it fetches it (if not available yet); for this, the selector must be exposed to all sub-levels; the response body by default buffers first/returns later for #to_s, and buffers and yields chunks on #each 2017-12-06 17:20:03 +00:00
HoneyryderChuck
46a1223187 addest tests for headers/request/response 2017-11-28 14:00:16 +00:00