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