View Javadoc

1   /*
2    * Copyright 2007 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.springframework.ws.transport.http;
18  
19  import java.net.URI;
20  
21  import org.springframework.ws.transport.WebServiceMessageSender;
22  
23  /**
24   * Abstract base class for {@link org.springframework.ws.transport.WebServiceMessageSender} implementations that use
25   * HTTP.
26   *
27   * @author Arjen Poutsma
28   * @since 1.0.0
29   */
30  public abstract class AbstractHttpWebServiceMessageSender implements WebServiceMessageSender {
31  
32      private boolean acceptGzipEncoding = true;
33  
34      /**
35       * Return whether to accept GZIP encoding, that is, whether to send the HTTP <code>Accept-Encoding</code> header
36       * with <code>gzip</code> as value.
37       */
38      public boolean isAcceptGzipEncoding() {
39          return acceptGzipEncoding;
40      }
41  
42      /**
43       * Set whether to accept GZIP encoding, that is, whether to send the HTTP <code>Accept-Encoding</code> header with
44       * <code>gzip</code> as value.
45       * <p/>
46       * Default is <code>true</code>. Turn this flag off if you do not want GZIP response compression even if enabled on
47       * the HTTP server.
48       */
49      public void setAcceptGzipEncoding(boolean acceptGzipEncoding) {
50          this.acceptGzipEncoding = acceptGzipEncoding;
51      }
52  
53      public boolean supports(URI uri) {
54          return uri.getScheme().equals(HttpTransportConstants.HTTP_URI_SCHEME) ||
55                  uri.getScheme().equals(HttpTransportConstants.HTTPS_URI_SCHEME);
56      }
57  }