Method: HTTPX::Response#bodyless?

Defined in:
lib/httpx/response.rb

#bodyless?Boolean

returns whether the response contains body payload.

Returns:

  • (Boolean)


118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/httpx/response.rb', line 118

def bodyless?
  @request.verb == "HEAD" ||
    @status < 200 || # informational response
    @status == 204 ||
    @status == 205 ||
    @status == 304 || begin
      content_length = @headers["content-length"]
      return false if content_length.nil?

      content_length == "0"
    end
end