01: /*
02: * Copyright 2007 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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 org.springframework.util.StringUtils;
20: import org.springframework.ws.transport.WebServiceMessageSender;
21:
22: /**
23: * Abstract base class for {@link org.springframework.ws.transport.WebServiceMessageSender} implementations that use
24: * HTTP.
25: *
26: * @author Arjen Poutsma
27: * @since 1.0.0
28: */
29: public abstract class AbstractHttpWebServiceMessageSender implements
30: WebServiceMessageSender {
31:
32: private boolean acceptGzipEncoding = true;
33:
34: protected static final String HTTP_HEADER_ACCEPT_ENCODING = "Accept-Encoding";
35:
36: protected static final String ENCODING_GZIP = "gzip";
37:
38: protected static final String HTTP_SCHEME = "http://";
39:
40: protected static final String HTTPS_SCHEME = "https://";
41:
42: /**
43: * Return whether to accept GZIP encoding, that is, whether to send the HTTP <code>Accept-Encoding</code> header
44: * with <code>gzip</code> as value.
45: */
46: public boolean isAcceptGzipEncoding() {
47: return acceptGzipEncoding;
48: }
49:
50: /**
51: * Set whether to accept GZIP encoding, that is, whether to send the HTTP <code>Accept-Encoding</code> header with
52: * <code>gzip</code> as value.
53: * <p/>
54: * Default is <code>true</code>. Turn this flag off if you do not want GZIP response compression even if enabled on
55: * the HTTP server.
56: */
57: public void setAcceptGzipEncoding(boolean acceptGzipEncoding) {
58: this .acceptGzipEncoding = acceptGzipEncoding;
59: }
60:
61: public boolean supports(String uri) {
62: return StringUtils.hasLength(uri)
63: && (uri.startsWith(HTTP_SCHEME) || uri
64: .startsWith(HTTPS_SCHEME));
65: }
66: }
|