private static WebResource . Builder ensureJsonHeaders ( MultivaluedMap < String , String > headers , WebResource . Builder requestBuilder , boolean contentType , boolean accept ) { boolean hasContentType = false ; boolean hasAccept = false ; if ( headers != null ) { for ( Map . Entry < String , List < String > > entry : headers . entrySet ( ) ) { String key = entry . getKey ( ) ; for ( String val : entry . getValue ( ) ) { if ( contentType && HttpHeaders . CONTENT_TYPE . equalsIgnoreCase ( key ) ) { hasContentType = true ; } else if ( accept && HttpHeaders . ACCEPT . equalsIgnoreCase ( key ) ) { hasAccept = true ; } requestBuilder = requestBuilder . header ( key , val ) ; } } } if ( ! hasContentType ) { requestBuilder = requestBuilder . type ( MediaType . APPLICATION_JSON ) ; } if ( ! hasAccept ) { requestBuilder = requestBuilder . accept ( MediaType . APPLICATION_JSON ) ; } return requestBuilder ; }
Adds the specified headers to the request builder . Provides default headers for JSON objects requests and submissions .