if (resourceRef.hasQuery()) {
final Form query = resourceRef.getQueryAsForm(null);
// Tunnel the request method
final Method method = request.getMethod();
if (tunnelService.isMethodTunnel()) {
final String methodName = query.getFirstValue(tunnelService
.getMethodParameter());
Method tunnelledMethod = Method.valueOf(methodName);
// The OPTIONS method can be tunnelled via GET requests.
if (tunnelledMethod != null
&& (Method.POST.equals(method) || Method.OPTIONS
.equals(tunnelledMethod))) {
request.setMethod(tunnelledMethod);