We have a client for our Restlet web service that puts the absolute URI in the 
http GET request line, which is a little non-standard.  Clients are supposed to 
send relative URIs unless they are talking to a proxy.  Nevertheless, http 
servers are supposed to handle this case and Restlet does not.  Actually it 
handles it as long as it isn't an https URI.

To reproduce this, connect to a local instance of a Restlet server:

>telnet localhost 8080
GET https://localhost/ HTTP/1.1
Host: localhost

HTTP/1.1 404 Not Found
Content-Length: 439
Content-Type: text/html; charset=UTF-8
Date: Sat, 15 Feb 2014 00:53:17 GMT
Server: Restlet-Framework/2.1.1

<html>
<head>
   <title>Status page</title>
</head>
<body style="font-family: sans-serif;">
<p style="font-size: 1.2em;font-weight: bold;margin: 1em 0px;">Not Found</p>
<p>The server has not found anything matching the request URI</p>
<p>You can get technical details <a 
href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5";>here</a>.<br>
Please continue your visit at our <a href="/">home page</a>.
</p>
</body>
</html>

I tried to work around this with a Filter but my beforeHandle() is never 
called.  The error seems to occur before any Filters are invoked.

The problem seems to be in org.restlet.data.Reference.getRemainingPart(boolean, 
boolean):

public String getRemainingPart(boolean decode, boolean query) {
  String result = null;
  final String all = toString(query, false);

  if (getBaseRef() != null) {
    final String base = getBaseRef().toString(query, false);

    if ((base != null) && all.startsWith(base)) {
      result = all.substring(base.length());
    }
  } else {
    result = all;
  }

  return decode ? decode(result) : result;
}

It is returning null because all.startsWith(base) is false; "all" has the https 
scheme and "base" has the http scheme.  Should I enter a defect for this?

We are running Restlet v2.1.1.

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3073193

Reply via email to