From 8893c2cbf06b3bc2b537a4e55e45056177d9a9e6 Mon Sep 17 00:00:00 2001 From: Will Jordan Date: Tue, 19 Jan 2021 09:24:19 -0800 Subject: [PATCH] Remove Server#read_body Unused method leftover from previous refactoring. --- History.md | 3 +++ lib/puma/server.rb | 56 ---------------------------------------------- 2 files changed, 3 insertions(+), 56 deletions(-) diff --git a/History.md b/History.md index a58970b7d5..6e322e2542 100644 --- a/History.md +++ b/History.md @@ -15,6 +15,9 @@ * Add `#string` method to `Puma::NullIO` ([#2520]) * Fix binding via Rack handler to IPv6 addresses (#2521) +* Refactor + * Remove `Server#read_body` ([#2531]) + ## 5.1.1 / 2020-12-10 * Bugfixes diff --git a/lib/puma/server.rb b/lib/puma/server.rb index aa8d3d4f8e..d60d64742f 100644 --- a/lib/puma/server.rb +++ b/lib/puma/server.rb @@ -495,62 +495,6 @@ def with_force_shutdown(client, &block) # :nocov: - # Given the request +env+ from +client+ and the partial body +body+ - # plus a potential Content-Length value +cl+, finish reading - # the body and return it. - # - # If the body is larger than MAX_BODY, a Tempfile object is used - # for the body, otherwise a StringIO is used. - # @deprecated 6.0.0 - # - def read_body(env, client, body, cl) - content_length = cl.to_i - - remain = content_length - body.bytesize - - return StringIO.new(body) if remain <= 0 - - # Use a Tempfile if there is a lot of data left - if remain > MAX_BODY - stream = Tempfile.new(Const::PUMA_TMP_BASE) - stream.binmode - else - # The body[0,0] trick is to get an empty string in the same - # encoding as body. - stream = StringIO.new body[0,0] - end - - stream.write body - - # Read an odd sized chunk so we can read even sized ones - # after this - chunk = client.readpartial(remain % CHUNK_SIZE) - - # No chunk means a closed socket - unless chunk - stream.close - return nil - end - - remain -= stream.write(chunk) - - # Read the rest of the chunks - while remain > 0 - chunk = client.readpartial(CHUNK_SIZE) - unless chunk - stream.close - return nil - end - - remain -= stream.write(chunk) - end - - stream.rewind - - return stream - end - # :nocov: - # Handle various error types thrown by Client I/O operations. def client_error(e, client) # Swallow, do not log