Permalink
Commits on Sep 10, 2017
  1. Release v3.0.0.pre

    ixti committed Sep 10, 2017
  2. Drop Ruby < 2.2 support.

    ixti committed Sep 10, 2017
    Ruby 2.1 was EOLed 5+ months ago. In face of v3.0.0 release it's time
    to drop support of 2.0 and 2.1 for us too.
  3. Fixup rubocop disable comment

    ixti committed Sep 10, 2017
  4. Upgrade rubocop to 0.49.1

    ixti committed Sep 10, 2017
Commits on Sep 8, 2017
  1. Merge pull request #429 from olleolleolle/patch-1

    tarcieri committed on GitHub Sep 8, 2017
    Travis: jruby-9.1.13.0
  2. Travis: jruby-9.1.13.0

    olleolleolle committed on GitHub Sep 8, 2017
Commits on Aug 18, 2017
  1. Give captured block to #each

    janko-m committed with ixti Jul 2, 2017
  2. Remove Enumerator from Request::Body#each

    janko-m committed with ixti Jul 2, 2017
    Using Enumerator interface like Enumerator#next wouldn't work correctly
    on JRuby with IOs, because JRuby eagerly loads the next element before
    it returns the current, and because each next chunk overwrites the
    previous one, it is impossible to retrieve first chunk via
    Enumerable#next.
    
    jruby/jruby#4583
    
    In order to avoid potential bugs in the future of someone wanting to use
    this Enumerator interface, we remove this entirely and mandate people to
    pass in a block.
  3. Fix tests on JRuby

    janko-m committed with ixti Jul 2, 2017
    IO.copy_stream on JRuby doesn't seem to limit the chunk size, it always
    reads the entire content at once.
    
    jruby/jruby#4701
    
    Since we don't care about what is the size of yielded chunks, we just
    test whether the yielded chunks sum up to the entire content.
    
    While here we also bring back HTTP::Request::Body#each returning an
    Enumerator, so that tests can be simpler.
  4. Remove extra line

    janko-m committed with ixti Jul 2, 2017
  5. Use IO.copy_stream for yielding chunks

    janko-m committed with ixti Jul 1, 2017
    IO.copy_stream already has the optimized behaviour of using #readpartial
    when available and a buffer string. So we create a BlockIO object that
    responds to #write, calling the underlying block with the given data,
    and returns the amount of written bytes. This BlockIO object can then be
    used as the "destination IO" in IO.copy_stream.
  6. Use a buffer string into which chunks will be read

    janko-m committed with ixti Jul 1, 2017
    IO#read and IO#readpartial accept an optional buffer string as a second
    argument. This will make it so that, instead of each chunk being
    allocated as a new string, each chunk is read into the buffer string
    (replacing any previous value). This means that no new strings will be
    allocated other than the buffer string on upload, so it's much more
    memory-efficient and gives less work to the GC.
    
    Previously we couldn't use a buffer string because of how JRuby
    implements Enumerators (it fetches the next chunk eagerly, replacing the
    one being returned). That's why we changed the implementation not to use
    Enumerators.
  7. Use #readpartial for reading content if available

    janko-m committed with ixti Jul 1, 2017
    IO#readpartial is preferable in cases where the IO is a stream such as a
    pipe or a socket. IO#readpartial differs from IO#read in situations
    where there is still some data immediately available, but not the number
    of bytes requested. IO#read would in this case block until the requested
    number of bytes is available, whereas IO#readpartial would immediately
    return the available data, and only block if there is no data available.
    
    Another technical difference is that, while IO#read simply returns nil
    when it has reached EOF, IO#readpartial raises an EOFError, so we have
    to rescue it.
    
    With IO#readpartial uploading from pipes should now be faster, because
    any data that is immediately available will be written to the TCP
    socket, so the upload is less blocked by the pipe retrieving data. This
    is also useful with the Down gem, which provides an IO object around a
    remote file, because again uploading is less blocked by the remote file
    being downloaded.
    
    This IO#readpartial preference is even baked into Ruby itself;
    `IO.copy_stream` will also prefer IO#readpartial over IO#read.
  8. Allow http_parser to decide if there is still body to read

    Bonias committed with ixti Aug 3, 2017
    It mostly fixes problem when connection which uses "Transfer-Encoding: chunked"
    header is closed to early before the terminating chunk is received. In such
    case "http" returned partial body instead of raising error.
  9. Merge pull request #426 from olleolleolle/patch-1

    ixti committed on GitHub Aug 18, 2017
    Travis: jruby-9.1.12.0, newer Bundler, RubyGems
Commits on Aug 17, 2017
Commits on May 29, 2017
  1. Adhere to the code style

    janko-m committed with ixti May 22, 2017
  2. Make auto deflate work with any request body

    janko-m committed with ixti May 22, 2017
    Previously auto deflating worked only for string bodies, so we
    generalize the implementation to work with any request body, by relying
    on the Request::Body abstraction.
    
    We also improve memory usage by yielding deflated chunks instead of
    returning the whole deflated body.
    
    On "Transfer-Encoding: chunked" requests the compressed body will be
    directly streamed to the socket as it is deflated, while on regular
    requests all of the body has to be deflated first so that we can obtain
    the body size for the "Content-Length" header before we start writing
    content.
  3. Merge pull request #414 from janko-m/return-response-body-chunks-in-s…

    ixti committed on GitHub May 29, 2017
    …pecified-encoding
    
    Return response body chunks in specified encoding
Commits on May 24, 2017
  1. Return response body chunks in specified encoding

    janko-m committed May 24, 2017
    MRI will return content read from the socket in the ASCII-8BIT (binary)
    encoding, whereas JRuby will return it in the UTF-8 encoding. In
    whichever encoding the body is retrieved, we want to force its encoding
    to the one specified (charset response header if present, otherwise
    binary). This is already the behaviour in Response#to_s, we just extend
    it to Response#readpartial as well.
    
    Fixes #413
Commits on May 19, 2017
  1. Merge pull request #409 from janko-m/enable-request-body-streaming

    ixti committed on GitHub May 19, 2017
    Enable request body streaming with an IO object
  2. Adhere to the code style

    janko-m committed May 2, 2017
  3. Don't use a buffer as a workaround for a JRuby bug

    janko-m committed May 2, 2017
    As described in jruby/jruby#4583, JRuby starts
    executing code after the first `yield` even though we requested only the
    first element, resulting in the first chunk being overriden with the
    second chunk before it was even returned.
    
    We work around this by not using a buffer string, therefore each
    retrieved chunk is a new string, so even if JRuby immediately retrieves
    the second chunk, it won't affect the first chunk.
  4. Fix a typo in tests

    janko-m committed May 2, 2017
  5. Allow chunked requests for any body type

    janko-m committed May 2, 2017
    Before creating chunked requests was only possible with Enumerable body.
    If "Transfer-Encoding: chunked" was set but the body wasn't Enumerable,
    request would be calculated as if it was a regular request, which meant
    inclusion of "Content-Length" header and writing request body as is. If
    body was an Enumerable but "Transfer-Encoding: chunked" wasn't set, an
    error would be raised.
    
    This commit enables sending chunked requests with any body type, by
    abstracting how the request body is read into an #each method. If
    "Transfer-Encoding: chunked" is detected, the yielded chunks are encoded
    accordingly before writing, otherwise the chunks are written as is.
    
    This allows making a streaming chunked request using an IO object, where
    file would be written in chunks of 16 KB, which wasn't previously
    possible.