Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8792765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:01:37+00:00 2026-06-13T23:01:37+00:00

I am using patron gem for creating curl request. Here is the code s

  • 0

I am using patron gem for creating curl request. Here is the code

    s = Patron::Session.new
    s.connect_timeout = 15
    s.timeout = 15
    s.base_url = API_URL
    s.headers['Date'] = DATE_HEADER
    s.headers['Accept'] = 'application/xml'
    s.headers['Content-Type'] = 'application/json'
    s.headers['Authorization'] = "API" + " " + auth_token
    response = s.delete(uri)
    response.status

How can I get the original curl request made by this gem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T23:01:37+00:00Added an answer on June 13, 2026 at 11:01 pm

    You can’t. Err… you can, by monkey_patching the Patron::Session.request method, and yielding the request just before the handling. But beware that this is not the “libcurl” request, as this only exists in C code, it’s a Patron::Request instance.

    Also, beware that your monkey-patching may break at any time, as you have to rewrite the whole method!

    You add a yield just before handling the request to libcurl, so you have the opportunity to get it with a block.

    req = nil
    response = s.delete(uri) do |r|
      req = r
    end
    # now req should be your request instance.
    

    Here is a hint for a patch:

    class Patron::Session
    
    # You have to patch all the standard methods to accept a block
    def get(url, headers = {}, &block)
      request(:get, url, headers, &block)
    end
    # do the same for get_file, head, delete, put, put_file, post, post_file and post_multipart
    
    
    def request(action, url, headers, options = {}, &block)
      # If the Expect header isn't set uploads are really slow
      headers['Expect'] ||= ''
    
      req = Request.new
      req.action                 = action
      req.headers                = self.headers.merge headers
      req.timeout                = options.fetch :timeout,               self.timeout
      req.connect_timeout        = options.fetch :connect_timeout,       self.connect_timeout
      req.max_redirects          = options.fetch :max_redirects,         self.max_redirects
      req.username               = options.fetch :username,              self.username
      req.password               = options.fetch :password,              self.password
      req.proxy                  = options.fetch :proxy,                 self.proxy
      req.proxy_type             = options.fetch :proxy_type,            self.proxy_type
      req.auth_type              = options.fetch :auth_type,             self.auth_type
      req.insecure               = options.fetch :insecure,              self.insecure
      req.ignore_content_length  = options.fetch :ignore_content_length, self.ignore_content_length
      req.buffer_size            = options.fetch :buffer_size,           self.buffer_size
      req.multipart              = options[:multipart]
      req.upload_data            = options[:data]
      req.file_name              = options[:file]
    
      base_url = self.base_url.to_s
      url = url.to_s
      raise ArgumentError, "Empty URL" if base_url.empty? && url.empty?
      uri = URI.join(base_url, url)
      query = uri.query.to_s.split('&')
      query += options[:query].is_a?(Hash) ? Util.build_query_pairs_from_hash(options[:query]) : options[:query].to_s.split('&')
      uri.query = query.join('&')
      uri.query = nil if uri.query.empty?
      url = uri.to_s
      req.url = url
    
      yield req if block_given? # added line
    
      handle_request(req)
    end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using a CSS image sprite, I'm creating an 'interactive' image where hovering over certain
I am new to ExtJS and have written a sample App using Ext.application with
Scope: Two tables. When a new patron is created, they have some information about
Using the new mvc4 now gives us access to use facebook oauth otb. I
Using a populated Table Type as the source for a TSQL-Merge. I want to
using this http://bl.ocks.org/950642 we can see how to add images to nodes, the question
Using SQL Server 2008 R2 we are looking for a way to select the
Using CI for the first time and i'm smashing my head with this seemingly
Using the Redis info command, I am able to get all the stats of
Using Location.getBearing(); I seem to get randomly changing bearings. Aka, I can turn the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.