uCosminexus Application Server, Web Service Development Guide

[Contents][Glossary][Index][Back][Next]

10.17 gzip compression of the HTTP request body

You can reduce the time required for the HTTP request communication between the Web Service client and the Web container by performing gzip compression of the HTTP request body. To compress the HTTP request body, you must attach the HTTP header indicating the sending of HTTP request body compressed in gzip format while sending the request message from the Web Service client. Implement the processing for attaching the HTTP header in the client application.

The following is an example of implementation in the client application:

  Map<String, List<String>> httpHeaders =
    ( Map<String, List<String>> )context.get( MessageContext.HTTP_REQUEST_HEADERS );
  if( null == httpHeaders ){
    httpHeaders = new HashMap<String, List<String>>();
  }
  List<String> contentEncondings = httpHeaders.get( "Content-Encoding" );
  if( null == contentEncondings ){
    contentEncondings = new ArrayList<String>();
  }
  contentEncondings.add( "gzip" );
  httpHeaders.put( "Content-Encoding", contentEncondings );
  context.put( MessageContext.HTTP_REQUEST_HEADERS, httpHeaders );