#11 ✓resolved
Matt Todd

Modifying Headers in Server Is Messy

Reported by Matt Todd | January 21st, 2008 @ 12:00 AM | in Release 0.4.0

There should be a cleaner way to modify headers (for all requests) and for specific requests. For instance, perhaps it should just be a class method like this:

class Foo < Halcyon::Server::Base
  headers :on => [:foo, :bar] do |req|
    req['Header-Field'] = 'Value'
    req
  end
end

Specifically with the Basic Authorization, it should only attempt authentication on actions that need it.

class Foo < Halcyon::Server::Auth::Basic
  basic_authorization :on => [:foo, :bar] do |user, pass|
    [user, pass] == ['rupert', 'secret']
  end
end

Comments and changes to this ticket

  • Matt Todd

    Matt Todd February 5th, 2008 @ 12:13 PM

    • State changed from “new” to “open”

    Fixed the clumsiness of the basic_authorization call, implementing almost exactly the example above. Instead of basic_authorization, the method is now called basic_auth, and it now accepts options for only certain actions or all except a few, though by default it requires basic authorization for all actions.

    For example:

    class Foo < Halcyon::Server::Auth::Basic
      basic_auth :only => [:foo, :bar] do |user, pass|
        [user, pass] == ['rupert', 'secret']
      end
    end
    
  • Matt Todd

    Matt Todd February 10th, 2008 @ 10:12 PM

    • State changed from “open” to “resolved”

    For now, this should be sufficient since, when performing requests, you can easily supply additional headers.

    For example.

    get('/foo/bar', {'X-Special-Header' => 'value'})
    

    This will be reevaluated in 0.5.0 when the server and client internals have been restructured for more elegant options for whole-application header values or callbacks allowing quick modification before being sent, but this will be sufficient for now.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

People watching this ticket

Pages