Rob Elsner | 23 Oct 19:41 2014

Feeling stupid - client connection gets closed early when relaying from network

We are trying to relay a FileRepresentation, and downloading directly from the Restlet server works fine. 
I can do a manual cURL/wget and retrieve the whole file correctly.

However, when relaying the input stream through a Servlet it seems like the client socket is being reset.

			Representation rep = myClient.get(MediaType.APPLICATION_OCTET_STREAM);

			response.setContentType("application/octet-stream");
			response.setHeader("Content-Disposition", "attachement; filename=\"" + fileName + "\"");
			outStream = response.getOutputStream();
			inStream = rep.getStream();
			byte[] buffer = new byte[65535000];
			int read = inStream.read(buffer, 0, 65535);
			while (read != -1)
			{
				outStream.write(buffer, 0, read);
				outStream.flush();
				read = inStream.read(buffer, 0, 65535);
			}
			outStream.flush();
			response.flushBuffer();

What we end up seeing on the server:

Caused by: java.nio.channels.ClosedChannelException
	at sun.nio.ch.SocketChannelImpl.ensureWriteOpen(SocketChannelImpl.java:135)
	at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:326)
	at org.simpleframework.transport.Appender.write(Appender.java:343)
	at org.simpleframework.transport.Appender.write(Appender.java:322)
	at org.simpleframework.transport.Appender.write(Appender.java:297)
(Continue reading)

Jared Davis | 23 Oct 02:35 2014

Restlet 2.2.2, Jetty 8.1, disable SSLv3

Hi,

What is the correct way to disable SSLv3 with Jetty 8.1?

I've tried disabledProtocols but it seems to have no effect.

    Server server = component.getServers().add(Protocol.HTTPS, ip, port);
        server.getContext().getParameters().add("keystorePath", keyPathname);
        server.getContext().getParameters().add("keystorePassword", storepass);
        server.getContext().getParameters().add("keyPassword",keypass );
        server.getContext().getParameters().add("disabledProtocols", "SSLv3");

Thanks,

Jared

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

Ralph van Etten | 20 Oct 11:22 2014

PATCH on Android with SSL gives 'Scheme https not registered'

Hi,

I have an Android application which uses the PATCH method.
When using the standard connector I get:

Communication Error (1001) - The connector failed to complete the 
communication with the server
....
Caused by: java.net.ProtocolException: Unknown method 'PATCH'; must be 
one of [OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE] at 
java.net.HttpURLConnection.setRequestMethod(HttpURLConnection.java:685)

So I use org.restlet.ext.httpclient and register it in my Android 
application:

Engine.getInstance().getRegisteredClients().clear();
Engine.getInstance().getRegisteredClients().add(new HttpClientHelper(null));

but now I get the following exception:

Internal Connector Error (1002) - The connector encountered an 
unexpected condition which prevented it from fulfilling the request
             at 
org.restlet.resource.ClientResource.doError(ClientResource.java:599)
...
      Caused by: java.lang.IllegalStateException: Scheme 'https' not 
registered.
             at 
org.apache.http.conn.scheme.SchemeRegistry.getScheme(SchemeRegistry.java:80)
             at 
(Continue reading)

Himani | 15 Oct 20:11 2014
Picon

Cookie set in request not received at Restlet servlet end

I have a Test Client which makes Restlet Request as below : 

public class TestRestlet {
public static void main(String[] args) throws IOException {
    CookieHandler.setDefault(new CookieManager( null, CookiePolicy.ACCEPT_ALL ));
    ClientResource resource = getClientResource();
    Representation rep = resource.get();
    System.out.println(rep.getText());

}

private static ClientResource getClientResource() {
    String resouceURL = "http://localhost:8080/ActivitiSampleProject/service/process-definitions?suspended=false";
    CookieSetting cookie1 = new CookieSetting("USER", "qdny6HjWY0HONvWoyufBWemrDE+5IcdsssssK0E8UGmu5RKPF7h0BWKvBPSn+Kucb82Aq");
    cookie1.setDomain(".abc.com");
    cookie1.setPath("/");
    cookie1.setMaxAge(-1);
    ClientResource resource = new ClientResource(resouceURL);
    resource.getRequest().getCookies().add(cookie1);
    return resource;
}
}

At Restlet Servlet I want to read these cookies from request and send them back to calling client to fetch
some information based on the cookie.

But I am unable to retrieve the cookies : I have set my debugger at service method of
org.restlet.ext.servlet.ServerServlet and the request has no cookies.

public void service(HttpServletRequest request, HttpServletResponse response)
(Continue reading)

Jerome Louvel | 15 Oct 15:13 2014

RE: Redirect whole browser traffic to restlet proxy

Hi Jovan,

Are you trying to setup a reverse proxy (server-side)?
If so, you need to set the mode to MODE_SERVER_OUTBOUND and use an URI template such as  "http://www.google.com/{rr}".

See Javadocs as well:
http://restlet.com/learn/javadocs/snapshot/jee/api/org/restlet/routing/Redirector.html

Best regards,
Jerome

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

Peter Hiesmair | 2 Oct 00:29 2014
Picon
Picon

Restlet web.xml config for new component

I have set up an App Engine Restlet Project (v 2.2.2) which returns a html or json response (web or android
client) and different data from a db for different users. I have implemented HTTP basic authentication.
It all works quite well.

my basic setup atm (I have simplified it ofc):

MyApplication.java
public class MyApplication extends Application {

    private ChallengeAuthenticator authenticatior;
    private ChallengeAuthenticator createAuthenticator() {...}
    public boolean authenticate(Request request, Response response) {...}

     <at> Override
    public Restlet createInboundRoot() {
        this.authenticatior = createAuthenticator();        
        Router router = new Router(getContext());
        router.attachDefault(MyRestlet.class);
        authenticatior.setNext(router);
        return authenticatior;
    }

MyRestlet.java
public class MyRestlet extends ServerResource {

         <at> Get("json")
        public Representation getJSON() {
            MyApplication app = (MyApplication) getApplication();
                if (!app.authenticate(getRequest(), getResponse())) {
                    // Not authenticated
(Continue reading)

Kay | 1 Oct 08:49 2014
Picon

OAuth2 example is broken when using client credentials as authorization grants

I tried OAuth2 example (org\restlet\example\ext\oauth\server\OAuth2Sample) in restlet 2.2.2.
However, in org.restlet.ext.oauth.TokenAuthServerResource, the username is required for the json
response or the TokenVerifier will throw exceptions. In client credential grants, it does not need a user
auth for access, am I right? 

Thanks.

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

Audumbar Pujari | 26 Sep 20:33 2014
Picon

Restlet server concurrency issue: Server handle multiple requests sequentially

Scenario :

  • I have implemented simple restlet server.

  • One client(RestClient / wget) or more than one client sending GET/POST requests to server at same time. (eg: wget http://mymachine.com:8182)

Expected Behavior :

  • Server needs to handle all requests concurrently.

Actual Behavior :

  • Server is handling all requests one by one (sequentially).

Project link:

I have created project on github.

Link for project : https://github.com/paudumbar/TestRESTServer

Am I missing any step in server creation?

Thanks.

Regards,

Audumbar

Laurent Rustuel | 12 Sep 18:26 2014

maven dependencies

Hello,
I'm wanted to try the swagger extension, and thus created a maven 
project with dependency to repository http://maven.restlet.org. When 
building with
<dependency>
<groupId>org.restlet.jee</groupId>
<artifactId>org.restlet</artifactId>
<version>2.3-SNAPSHOT</version>
</dependency>
I've the following error :
[ERROR] Failed to execute goal on project ucs-web: Could not resolve 
dependencies [...]
collect dependencies at 
org.restlet.jee:org.restlet.ext.swagger:jar:2.3-SNAPSHOT ->

org.restlet.jee:org.restlet.lib.org.restlet.lib.org.eclipse.e4.core.contexts:jar:${lib-e4-version}: 
Failed to read artifact descriptor for 
org.restlet.jee:org.restlet.lib.org.restlet.lib.org.eclipse.e4.core.contexts:
jar:${lib-e4-version}: Could not transfer artifact

org.restlet.jee:org.restlet.lib.org.restlet.lib.org.eclipse.e4.core.contexts:pom:${lib-e4-version} 
from/to maven-restlet (http://maven.restlet.org): Illegal character in 
path at index 103:

http://maven.restlet.org/org/restlet/jee/org.restlet.lib.org.restlet.lib.org.eclipse.e4.core.contexts/${lib-e4-version}/org.restlet.lib.org.restlet.lib.org.eclipse.e4.core.contexts-${lib-e4-version}.pom 

If I set this version
mvn compile -Dlib-e4-version=0.12.RC1
I then got the following error :

[ERROR] Failed to execute goal on project test-swagger: Could not 
resolve dependencies for project 
com.genesys.ucs.esp:ucs-web:jar:9.0-SNAPSHOT: Failed to collect 
dependencies at org.restlet.jee:org.restlet.ext.swagger:jar:2.3-SNAPSHOT 
-> javax.ws.rs:javax.ws.rs-api:jar:2.0.0: Failed to read artifact 
descriptor for javax.ws.rs:javax.ws.rs-api:jar:2.0.0: Could not transfer 
artifact javax.ws.rs:javax.ws.rs-api:pom:2.0.0 from/to maven1-java 
(http://download.java.net/maven/1): No connector available to access 
repository maven1-java (http://download.java.net/maven/1) of type legacy 
using the available factories WagonRepositoryConnectorFactory -> [Help 1]

I'm not sur if this is an incorrect settings in my project or if this is 
an issue.

Regards,
Laurent.

--

-- 
Laurent Rustuel,
Software Engineer
Genesys Telecommunications Lab
Askell Park – 90 Rue Charles Nungesser
ZAC Prat Pip Nord
29490 Guipavas, France
T:  +33 2 57 40 13 37

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

hshorter | 9 Sep 17:45 2014

HTTP -> HTTPS redirect

Is there a way to redirect a browser from HTTP to HTTPS?

For example, I enter "localhost:1234/MyApplication" into a browser and I would like it to redirect to "https://localhost:1234/MyApplication".

Thanks.

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

Ziemowit Stolarczyk | 4 Sep 14:06 2014

ClientResource and proxy settings

Hi!

We have following problem.

1. We use org.restlet.resource.ClientResource in our code.
2. We set up http.nonProxyHosts setting but it does not help. Code always tries to use proxy.

Does ClientResource is able to cooperate with nonProxyHosts setting or should we use different approach?

Could You help?

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


Gmane