private void setHttpRequestHeaders(MessageContext msgContext, HttpRequest httpRequest) {
    @SuppressWarnings("unchecked")
    Map<Object, Object> requestHeaders =
        (Map<Object, Object>) msgContext.getProperty(HTTPConstants.REQUEST_HEADERS);
    if (requestHeaders != null) {
      for (Entry<Object, Object> headerEntry : requestHeaders.entrySet()) {
        Object headerKey = headerEntry.getKey();
        if (headerKey == null) {
          continue;
        }
        String headerName = headerKey.toString().trim();
        Object headerValue = headerEntry.getValue();
        if (HTTPConstants.HEADER_AUTHORIZATION.equals(headerName)
            && (headerValue instanceof String)) {
          // HttpRequest expects the Authorization header to be a list of values,
          // so handle the case where it is simply a string.
          httpRequest.getHeaders().setAuthorization((String) headerValue);
        } else {
          httpRequest.getHeaders().set(headerName, headerValue);
        }
      }
    }
    if (msgContext.isPropertyTrue(HTTPConstants.MC_GZIP_REQUEST)) {
      httpRequest.getHeaders().setContentEncoding(HTTPConstants.COMPRESSION_GZIP);
    }
  }
private void setHttpRequestHeaders ( MessageContext msgContext , HttpRequest httpRequest ) { @ SuppressWarnings ( "unchecked" ) Map < Object , Object > requestHeaders = ( Map < Object , Object > ) msgContext . getProperty ( HTTPConstants . REQUEST_HEADERS ) ; if ( requestHeaders != null ) { for ( Entry < Object , Object > headerEntry : requestHeaders . entrySet ( ) ) { Object headerKey = headerEntry . getKey ( ) ; if ( headerKey == null ) { continue ; } String headerName = headerKey . toString ( ) . trim ( ) ; Object headerValue = headerEntry . getValue ( ) ; if ( HTTPConstants . HEADER_AUTHORIZATION . equals ( headerName ) && ( headerValue instanceof String ) ) { httpRequest . getHeaders ( ) . setAuthorization ( ( String ) headerValue ) ; } else { httpRequest . getHeaders ( ) . set ( headerName , headerValue ) ; } } } if ( msgContext . isPropertyTrue ( HTTPConstants . MC_GZIP_REQUEST ) ) { httpRequest . getHeaders ( ) . setContentEncoding ( HTTPConstants . COMPRESSION_GZIP ) ; } }
Sets HTTP request headers based on the Axis message context.