Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to disable chunked-transfer-encoding in grizzly based http-server

Tags:

java

grizzly

I am developing a grizzly-based-server that should communicate with a lot of clients. Basically, I created a listener that listens to a specific port and I add this listener to my http-server-instance. Since I need very simple communication between my clients and my grizzly-server, I want to disable chunked Transfer-Encoding. According to this link https://grizzly.java.net/httpserverframework.html, I can enable/disable HTTP-related features of my listener such as chunked transfer-encoding. I tried to find a way to do it but it was not successfull. Here is some code.

HttpServer server = HttpServer.createSimpleServer();
server.getServerConfiguration().addHttpHandler(new myHandler());
//add new listener
NetworkListener nt=new NetworkListener("myServer",ip_adresse,port);
server.addListener(nt);
try {
        //start the server
        server.start();
        Thread.currentThread().join();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

Any Idea?

like image 576
amitakCs Avatar asked Sep 15 '15 12:09

amitakCs


1 Answers

Please use NetworkListener to disable chunking:

networkListener.setChunkingEnabled(false);
like image 70
alexey Avatar answered Nov 02 '22 17:11

alexey