{"record":{"id":"6fb478ee75f4a4fa","repo":"bblimke/webmock","slug":"both-arg-and-block-given-for-http-method","errorCode":null,"errorMessage":"both arg and block given for HTTP method","messagePattern":"both arg and block given for HTTP method","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/webmock/http_lib_adapters/net_http_response.rb","lineNumber":24,"sourceCode":"# is called with a destination string or block.\n#\n# This causes a problem when VCR records a response--it reads the body before yielding\n# the response, and if the code that is consuming the HTTP requests uses #read_body, it\n# can cause an error.\n#\n# This is a bit of a hack, but it allows a Net::HTTP response to be \"re-read\"\n# after it has aleady been read.  This attemps to preserve the behavior of\n# #read_body, acting just as if it had never been read.\n\n\nmodule Net\n  module WebMockHTTPResponse\n    def read_body(dest = nil, &block)\n      if !(defined?(@__read_body_previously_called).nil?) && @__read_body_previously_called\n        return super\n      end\n      return @body if dest.nil? && block.nil?\n      raise ArgumentError.new(\"both arg and block given for HTTP method\") if dest && block\n      return nil if @body.nil?\n\n      dest ||= ::Net::ReadAdapter.new(block)\n      dest << @body.dup\n      @body = dest\n    ensure\n      # allow subsequent calls to #read_body to proceed as normal, without our hack...\n      @__read_body_previously_called = true\n    end\n  end\nend\n\n","sourceCodeStart":6,"sourceCodeEnd":37,"githubUrl":"https://github.com/bblimke/webmock/blob/b187df8827e1f08a1684a8ddc0a5050dbd449c16/lib/webmock/http_lib_adapters/net_http_response.rb#L6-L37","documentation":"Error \"both arg and block given for HTTP method\" thrown in bblimke/webmock.","triggerScenarios":"Thrown at lib/webmock/http_lib_adapters/net_http_response.rb:24 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b187df8827e1f08a1684a8ddc0a5050dbd449c16","analyzedAt":"2026-08-23T02:55:22.028Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}