Hi All,

My application exposes multiple rest services, which is deployed in a
jettycontainer (Jettyrunner jetty-9.4.0.v20161208).

I don't want my response to be chunked. Hence used attached jetty.xml
configuration to increase the output buffer size. It was working without
any issue. Suddenly after a release it stopped working and after some
investigation we found that we had removed one custom servlet filer from
codebase as it is no longer required and hence jetty started chunking the
response.

This custom filter is used to alter the response. If this filer is there
then chunking is stopped and I can see proper content length response
header.

How can I fix this without a filer? Can anybody explain me what is really
happening here?

My filter sample code is below.

public class ContentFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) {}

    @Autowired
    ContentServiceImpl contentServiceImpl;

    @Override
    public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
        HttpServletRequest httpRequest = (HttpServletRequest) request;
        ResponseWrapper responseWrapper = new
ResponseWrapper((HttpServletResponse) response);
        chain.doFilter(request, responseWrapper);
        String responseContent = new
String(responseWrapper.getDataStream());

        //MANIPLATING THE responseContent

        response.getOutputStream().write(responseContent.getBytes());
    }

    @Override
    public void destroy() {}
}

Thanks
Rajiv
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd";>

<Configure id="Server" class="org.eclipse.jetty.server.Server">
    <!-- Configuring the buffer size and aggregation size of the out response -->
    <New id="httpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
        <Set name="outputBufferSize">
            <Property name="jetty.httpConfig.outputBufferSize" deprecated="jetty.output.buffer.size" default="1048576" />
        </Set>
        <Set name="outputAggregationSize">
            <Property name="jetty.httpConfig.outputAggregationSize" deprecated="jetty.output.aggregation.size" default="1048576" />
        </Set>
    </New>
    <Call name="addConnector">
        <Arg>
            <New class="org.eclipse.jetty.server.ServerConnector">
                <Arg name="server">
                    <Ref refid="Server" />
                </Arg>
                <Arg name="acceptors" type="int">
                    <Property name="http.acceptors" default="-1" />
                </Arg>
                <Arg name="selectors" type="int">
                    <Property name="http.selectors" default="-1" />
                </Arg>
                <Arg name="factories">
                    <Array type="org.eclipse.jetty.server.ConnectionFactory">
                        <Item>
                            <New class="org.eclipse.jetty.server.HttpConnectionFactory">
                                <Arg name="config">
                                    <Ref refid="httpConfig" />
                                </Arg>
                            </New>
                        </Item>
                    </Array>
                </Arg>
                <Set name="host">
                    <Property name="jetty.host" />
                </Set>
                <Set name="port">
                    <Property name="jetty.port" default="8080" />
                </Set>
                <Set name="idleTimeout">
                    <Property name="http.timeout" default="30000" />
                </Set>
                <Set name="soLingerTime">
                    <Property name="http.soLingerTime" default="-1" />
                </Set>
                <Set name="acceptQueueSize">
                    <Property name="http.acceptQueueSize" default="0" />
                </Set>
            </New>
        </Arg>
    </Call>
    <!-- Force all communication over secure channels. -->
    <Set name="handler">
      <New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection">
        <Set name="handlers">
         <Array type="org.eclipse.jetty.server.Handler">
           <Item>
             <New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
           </Item>
           <Item>
             <New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/>
           </Item>
		   <Item>
			  <New id="RequestLogHandler"
				   class="org.eclipse.jetty.server.handler.RequestLogHandler"/>
			</Item>
         </Array>
        </Set>
      </New>
    </Set>
	
	<Ref id="RequestLogHandler">
	  <Set name="requestLog">
		<New id="requestLogImpl" class="ch.qos.logback.access.jetty.RequestLogImpl">
		<Set name="fileName">etc/logback-access.xml</Set>
		   <Set name="name">logback-access</Set>
		      <Set name="resource">logback-access.xml</Set>
		      <Call name="start"/>
		</New>   
	  </Set>
	</Ref>
</Configure>
_______________________________________________
jetty-users mailing list
[email protected]
To change your delivery options, retrieve your password, or unsubscribe from 
this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users

Reply via email to