Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support HTTP PURGE verb (and maybe other custom ones) #35

Closed
corasaurus-hex opened this issue Feb 11, 2013 · 3 comments
Closed

Support HTTP PURGE verb (and maybe other custom ones) #35

corasaurus-hex opened this issue Feb 11, 2013 · 3 comments
Labels

Comments

@corasaurus-hex
Copy link
Contributor

I'm not sure if this belongs in Typhoeus or Ethon, but Typhoeus used to support HTTP PURGE which is used by HTTP caches like Varnish to signal that entries should be removed.

The error I get now is: uninitialized constant Ethon::Easy::Http::Purge.

If I add this, the request works (it just copies Ethon::Easy::Http::Get):

module Ethon
  class Easy
    module Http

      # This class knows everything about making GET requests.
      class Purge
        include Ethon::Easy::Http::Actionable
        include Ethon::Easy::Http::Postable

        # Setup easy to make a GET request.
        #
        # @example Setup.
        #   get.set_params(easy)
        #
        # @param [ Easy ] easy The easy to setup.
        def setup(easy)
          super
          easy.customrequest = "GET" unless form.empty?
        end
      end
    end
  end
end

But maybe there's a way to allow for custom HTTP verbs?

@hanshasselberg
Copy link
Member

I agree there should be a way to do a custom request. Not sure though how to do it...
Your implementation looks fine except for one line:

easy.customrequest = "GET" unless form.empty?

which should be

easy.customrequest = "PURGE"

Your purge would actually do a GET and shouldn't work.

I imagine a custom request to work like that:

Typhoeus::Request.new("www.example.com", method: 'purge')
#=> Ethon cannot find a class and uses Ethon::Easy::Http::Custom which would look quite similar to yours.

What do you think?

@corasaurus-hex
Copy link
Contributor Author

I took a stab at it here: #36

@GabrSaac
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants