Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
    @raghuvarmabh You're adding the logger twice this way, I guess that's unintentional, you can merge the two lines like this:
    builder.response(:logger, nil, headers: true, bodies: true,
                     log_level: Rails.application.config.log_level) do |logger|
      logger.filter(/(Authorization)([^&]+)/, '\1[REMOVED]')
    raghu bhupatiraju
    ya thats the issue for seeing duplicate logs. Thanks again @iMacTia for quick resonse.
    Will it be helpful to add a filter_auth flag to logger which does the filtering thing. I will be happy to open a PR.
    You’re welcome @raghuvarmabh 🙌!
    filter_auth sounds a bit too specific. Maybe a more generic method to filter headers? I’d suggest opening an issue before jumping on an implementation so we could discuss a proposal (how would that be used, how it will differ from the current filter method, …)
    Dan Milne
    Hi guys - I have a problem where a header I'm adding to a request "authorizationToken" is having its case changed to "Authorizationtoken". The server apparently is case sensitive and returns a 500 when the case is changed.
    Hey @dkam, that might be because you're using symbols to set headers or a known issue affecting Net::HTTP, I posted some more details in this comment: https://github.com/lostisland/faraday/issues/747#issuecomment-439864181
    Eddie Cheung
    Hi guys, I am new to use Faraday connection for sending POST request. Based on some research, I notice that using net_http_persistent adapter (instead of the Faraday.default_adapter (which is net_http according to the Faraday documentation) will improve performance due to reusing the same connection. Basically, I would like to learn the best practice on some of the setting (like pool_size, idle_timeout, keep_alive and max_requests) for net_http_persistent adapter in order have a high performance and stable Faraday connection. Thanks in advance.
    Hi @eddiecheung-shopify and thanks for joining! I personally don't have expertise in every Faraday adapter (hence why we recently went through the work of splitting them into their own repos), so I don't feel like the best person to provide "bets practices values" for their configuration. I hope someone here (@/all) will be able to help, but otherwise you could reach out to the net-http-persistent team and ask them about this. In the end, Faraday is just a wrapper on the adapters, so whatever they suggest as the best approach will work in Faraday as well
    1 reply


    We've decided to move over to GitHub Discussions for community discussions on getting help and asking questions.
    The Faraday core team will not be monitoring this chat anymore, but you're more than welcome to stay and continue the discussion if you prefer.
    If you want to reach out to the Faraday core team, you can find us here
    Samuel Williams
    @eddiecheung-shopify you should check out the async backend.
    Hi all, In below shared code, commented line is old one, old code is returning faraday.headers is {"Authorization"=>"Bearer access_token"}, but when i added new code, faraday.headers is empty !
    def initialize(options = {})
    @config = Sso::Configure.new(options)
    access_token = @config.access_token
      @conn = Faraday.new(url: Sso::BASE_URL) do |faraday|
        # faraday.authorization :Bearer, access_token if access_token.present?
        faraday.request :authorization, :Bearer, access_token if access_token.present?
        faraday.request :json
        faraday.response :json
        faraday.adapter Faraday.default_adapter
    Please help me on this
    Lewis Cowles
    @giri5681 fairly certain it is that comma after :authorization, :Bearer... which was previously :authorization :Bearer, ...
    https://lostisland.github.io/faraday/usage/#:~:text=Detailed%20HTTP%20Requests shows using a block if making multiple calls, in the same way you have.
    Although https://lostisland.github.io/faraday/middleware/authentication#with-a-proc says I am incorrect in this and the comma is not the issue.
    Vibhanshu Jain
    Hi folks
    I am a newbie here
    Can anyone suggest me how to run the test cases with faraday
    basically how to start, any documentation except official website etc
    Wei Jun
    what do you mean how to run test cases with faraday? are you talking about writing rspecs?
    Vibhanshu Jain

    I am using faraday with rspec for single request I am facing below issue
    undefined method `register_middleware' for Faraday::Adapter:Class

      Faraday::Adapter.register_middleware(net_http: Faraday::Adapter::NetHttp)

    I have tried to install faraday_middleware gem but it is not found
    Not sure where I am worng

    Rod Jenkins
    hello all. Can someone point me to an example of using Faraday to download very large files? It looks like it is reading the file in to memory, which will not work on a 75G file, lol.
    1 reply
    Samuel Williams
    @scriptmonkey If you are interested in robust chunked (HTTP range) downloading check out https://github.com/socketry/async-http/blob/main/examples/download/chunked.rb

    Hello all!
    I am new to faraday and net-http (we use the default adapter). I have a rails application and it calls many other services to fetch data using faraday gem. However, we are experiencing a lot of timeout errors and we were thinking of reducing the timeout value etc...

    I wanted to try one thing, I wanted to collect few data here.
    Given that I want to perform a GET API request
    I want to log or print the value of the time it takes to open the connection with the server
    And I also want to log or print the time it takes till the client starts or ends receiving the response back from the server
    And I also want to log or print the time it takes to close the connection with the server.

    (Iterating again, I am using Rails application :) ) How can I achieve this? Thanks!

    Eric Pugh
    Hi all.. Checking out Faraday to integrate into the Quepid project (github.com/o19s/quepid). Quepid interacts with various search engines via the users Browser hitting the search engine. Now that Chrome is getting tighter on permissions, I am looking at moving that logic from the client JS app to the Rails app on the server side.
    3 replies
    Martin Streicher
    I assume this is the new API call to do Bearer token... f.request :authorization, :Bearer, scanner_token
    Where does the documentation explain what things get called via f.request?
    Hi All,
    I was using faraday 1.7.1 where I was using f.request :retry during connection initialization. My colleague updated the gem to 2.2.0 and it started failing with :retry is not registered on Faraday::Request error. How to configure this for 2.2.0?

    I think I found it. Under release docs


    gem 'faraday-multipart'
    gem 'faraday-retry'

    Connection initializer

    require 'faraday/retry'
    require 'faraday/multipart'

    conn = Faraday.new(url) do |f|
    f.request :multipart
    f.request :retry



    Simon Hönscheid
    Hello Community, I try to convert a curl request using forms to faraday, the curl request is documented here: https://developer.atlassian.com/cloud/confluence/rest/api-group-content---attachments/#api-wiki-rest-api-content-id-child-attachment-put
    I have this code so far and the upload itself is working:
    require 'faraday'
    require 'faraday/multipart'
    cloud_upload_connection = Faraday.new(cloud_url) do |c|
      c.request :multipart
      c.request :url_encoded
      c.request :authorization, :basic, cloud_useremail, cloud_apitoken
      c.adapter :net_http
      c.headers['X-Atlassian-Token'] = 'nocheck'
    # upload attachment
    payload = { :file => Faraday::UploadIO.new("#{download_directory}/#{page['id']}.csv", 'text/plain') }
    cloud_upload_connection.put( "rest/api/content/#{cloud_page_details['id'].to_i}/child/attachment", payload)
    How do I add the form Data?