Hi,

Came across an issue when were trying do some SEO optimization  and I
wanted to know if anyone else had seen this problem or worked around
it.

Seems that some spiders use HEAD requests to verify that a resource
exists, and it also seems that Merb currently doesn't support HEAD
requests for resource-based routes.

I found this ticket,
http://merb.lighthouseapp.com/projects/7433/tickets/416-head-request-should-be-routed-the-same-as-get,
which breaks the problem down into a 3 part solution, courtesy of Dan
Kubb and Michael Klishin

I'm on rack 0.9.1 , so I believe that this version has included the
patch mentioned here : 
http://groups.google.com/group/rack-devel/browse_thread/thread/be2c6e273e015119
, courtesy of Ben Alpert.

The final piece seems to be in the router.  I tried digging into the
source code and came across the realization that the compiled match
method, when using resource routes, does explicit matches against
request methods .  In other words, a set of resource routes may look
like  :

  elsif (/^\/topics\/([^\/.,;?]+)(?:\.([^\/.,;?]+))?$/ =~ cached_path
&& ((path1, path2 = $1, $2) || true)) && (cached_method == "get")
    [21, {:format => (path2), :controller => "topics", :action =>
"show", :id => (path1)}]
  elsif (/^\/topics\/([^\/.,;?]+)\/edit(?:\.([^\/.,;?]+))?$/ =~
cached_path  && ((path1, path2 = $1, $2) || true)) && (cached_method
== "get")
    [22, {:format => (path2), :controller => "topics", :action =>
"edit", :id => (path1)}]
  elsif (/^\/topics\/([^\/.,;?]+)\/delete(?:\.([^\/.,;?]+))?$/ =~
cached_path  && ((path1, path2 = $1, $2) || true)) && (cached_method
== "get")
    [23, {:format => (path2), :controller => "topics", :action =>
"delete", :id => (path1)}]
  elsif (/^\/topics\/([^\/.,;?]+)(?:\.([^\/.,;?]+))?$/ =~ cached_path
&& ((path1, path2 = $1, $2) || true)) && (cached_method == "put")
    [24, {:format => (path2), :controller => "topics", :action =>
"update", :id => (path1)}]
  elsif (/^\/topics\/([^\/.,;?]+)(?:\.([^\/.,;?]+))?$/ =~ cached_path
&& ((path1, path2 = $1, $2) || true)) && (cached_method == "delete")

I'm not sure what the "correct" approach is for resolving that.

One the one hand, the HTTP spec states that HEAD requests should
behave just like GET requests, which indicates that maybe the route
compiler needs to be updated to support "get or head" in the show
cases.   On the other hand, HEAD being a different verb altogether
seems a logical understanding, imho

I should point out that pure 'match' requests don't have this issue
unless explicitly stating a request method.

I would be most curious to hear any thoughts on the matter, and if
people have encountered this and/or anything they did to work around
it.

Many thanks,

-a
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"merb" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/merb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to