* @param request
* The request to update.
* @return True if the query has been updated, false otherwise.
*/
private boolean processQuery(Request request) {
TunnelService tunnelService = getTunnelService();
boolean queryModified = false;
Reference resourceRef = request.getResourceRef();
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);
query.removeFirst(tunnelService.getMethodParameter());
queryModified = true;
}
}
// Tunnel the client preferences
if (tunnelService.isPreferencesTunnel()) {
// Get the parameter names to look for
String charSetParameter = tunnelService
.getCharacterSetParameter();
String encodingParameter = tunnelService.getEncodingParameter();
String languageParameter = tunnelService.getLanguageParameter();
String mediaTypeParameter = tunnelService
.getMediaTypeParameter();
// Get the preferences from the query
String acceptedCharSet = query.getFirstValue(charSetParameter);
String acceptedEncoding = query