List of usage examples for org.springframework.util StringUtils toLanguageTag
@Deprecated public static String toLanguageTag(Locale locale)
From source file:com.duowan.common.rpc.client.CommonsHttpInvokerRequestExecutor.java
/** * Create a PostMethod for the given configuration. * <p>The default implementation creates a standard PostMethod with * "application/x-java-serialized-object" as "Content-Type" header. * @param config the HTTP invoker configuration that specifies the * target service//ww w.j a v a 2 s . com * @return the PostMethod instance * @throws IOException if thrown by I/O methods */ protected PostMethod createPostMethod(String serviceUrl) throws IOException { PostMethod postMethod = new PostMethod(serviceUrl); LocaleContext locale = LocaleContextHolder.getLocaleContext(); if (locale != null) { postMethod.addRequestHeader(HTTP_HEADER_ACCEPT_LANGUAGE, StringUtils.toLanguageTag(locale.getLocale())); } if (isAcceptGzipEncoding()) { postMethod.addRequestHeader(HTTP_HEADER_ACCEPT_ENCODING, ENCODING_GZIP); } return postMethod; }
From source file:com.baidu.jprotobuf.rpc.client.SimpleHttpRequestExecutor.java
/** * Prepare the given HTTP connection./*from w w w .j av a 2 s . com*/ * <p>The default implementation specifies POST as method, * "application/x-java-serialized-object" as "Content-Type" header, * and the given content length as "Content-Length" header. * @param con the HTTP connection to prepare * @param contentLength the length of the content to send * @throws IOException if thrown by HttpURLConnection methods * @see java.net.HttpURLConnection#setRequestMethod * @see java.net.HttpURLConnection#setRequestProperty */ protected void prepareConnection(HttpURLConnection con, int contentLength) throws IOException { con.setDoOutput(true); con.setRequestMethod(HTTP_METHOD_POST); con.setRequestProperty(HTTP_HEADER_CONTENT_TYPE, getContentType()); con.setRequestProperty(HTTP_HEADER_CONTENT_LENGTH, Integer.toString(contentLength)); LocaleContext locale = LocaleContextHolder.getLocaleContext(); if (locale != null) { con.setRequestProperty(HTTP_HEADER_ACCEPT_LANGUAGE, StringUtils.toLanguageTag(locale.getLocale())); } if (isAcceptGzipEncoding()) { con.setRequestProperty(HTTP_HEADER_ACCEPT_ENCODING, ENCODING_GZIP); } }
From source file:org.springframework.remoting.httpinvoker.HttpComponentsHttpInvokerRequestExecutor.java
/** * Create a HttpPost for the given configuration. * <p>The default implementation creates a standard HttpPost with * "application/x-java-serialized-object" as "Content-Type" header. * @param config the HTTP invoker configuration that specifies the * target service//from w w w .j av a2 s . com * @return the HttpPost instance * @throws java.io.IOException if thrown by I/O methods */ protected HttpPost createHttpPost(HttpInvokerClientConfiguration config) throws IOException { HttpPost httpPost = new HttpPost(config.getServiceUrl()); LocaleContext locale = LocaleContextHolder.getLocaleContext(); if (locale != null) { httpPost.addHeader(HTTP_HEADER_ACCEPT_LANGUAGE, StringUtils.toLanguageTag(locale.getLocale())); } if (isAcceptGzipEncoding()) { httpPost.addHeader(HTTP_HEADER_ACCEPT_ENCODING, ENCODING_GZIP); } return httpPost; }
From source file:spring.test.web.HttpComponentsHttpInvokerRequestExecutor.java
/** * Create a HttpPost for the given configuration. * <p>The default implementation creates a standard HttpPost with * "application/x-java-serialized-object" as "Content-Type" header. * @param config the HTTP invoker configuration that specifies the * target service//from w w w .j av a 2 s. c o m * @return the HttpPost instance * @throws java.io.IOException if thrown by I/O methods */ protected HttpPost createHttpPost(HttpInvokerClientConfiguration config) throws IOException { HttpPost httpPost = new HttpPost(config.getServiceUrl()); LocaleContext locale = LocaleContextHolder.getLocaleContext(); if (locale != null) { httpPost.addHeader(HTTP_HEADER_ACCEPT_LANGUAGE, StringUtils.toLanguageTag(locale.getLocale())); } if (isAcceptGzipEncoding()) { httpPost.addHeader(HTTP_HEADER_ACCEPT_ENCODING, ENCODING_GZIP); } return httpPost; }