Skip to content

Restlet truncates response (Redirector) #951

Open
@kerbymart

Description

@kerbymart

I tried this code below at localhost, the expected was that the reponse to be complete but its not like this:

      <div id="works" class="second-content"><!-- Second Content -->
        <div class="content textaligncenter">
          <h1>Featured Projects</h1>

          <div class="portfolio">
            <div class

Notice the broken div tag.

Code:

public class FirstStepsApplication extends Application {
        private static final String ROOT_URI = "/";
        @Override
        public Restlet createInboundRoot() {
            Router router = new Router(getContext());
            Redirector proxy = new Redirector(getContext(), Constants.root,
                    Redirector.MODE_SERVER_OUTBOUND){
                @Override
                public void handle(Request request, Response response) {
                    String path = request.getResourceRef().getHostIdentifier() +
                            request.getResourceRef().getPath();
                    try {
                        URL url = new URL(path);
                        String host = url.getHost();
                        String pathParts = url.getPath();
                        if(pathParts.isEmpty() || pathParts.equals(ROOT_URI)){
                            pathParts = "/index.html";
                        }
                        String targetPattern = Constants.root + host + pathParts;
                        this.setTargetTemplate(targetPattern);
                    } catch (MalformedURLException e){
                        e.printStackTrace();
                    }
                    super.handle(request, response);
                }
            };
            getConnectorService().getClientProtocols().add(Protocol.HTTP);
            router.attachDefault(proxy);
            return router;
        }
    }

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions