Skip to content

verbose flag changes on_body callback exception behavior #266

@sjshapiro

Description

@sjshapiro

The behavior of exceptions thrown from an on_body handler differs based upon the value passed to the verbose switch. Ideally the behavior should be the same or the difference in behavior documented if intentional.

You can run this example code to see a demonstration of the issue:

#!/usr/bin/env ruby

require 'ethon'

# Use a healthy endpoint of your choice
URL = "http://0.0.0.0"

handler = proc do
  raise "My Exception"
end

puts "Running with verbose: true"
easy = Ethon::Easy.new(url: URL, verbose: true)
easy.on_body(&handler)
easy.perform
puts "No exception here: #{easy.return_code}"

puts "Running with verbose: false"
easy2 = Ethon::Easy.new(url: URL, verbose: false)
easy2.on_body(&handler)
easy2.perform
puts "This will never print."

Note that the when verbose is true an exception is not thrown.

A quick review of the cURL source wasn't helpful. I believe the issue lies either in ethon or ffi, but was not able to determine where.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions