Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||||||
RequestData |
|
| 1.0;1 |
1 | /* |
|
2 | * Copyright 1999,2005 The Apache Software Foundation. |
|
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 | package org.apache.xmlrpc.webserver; |
|
17 | ||
18 | import org.apache.xmlrpc.common.XmlRpcHttpRequestConfigImpl; |
|
19 | ||
20 | ||
21 | /** Web servers extension of |
|
22 | * {@link org.apache.xmlrpc.common.XmlRpcHttpRequestConfig}, |
|
23 | * which allows to store additional per request data. |
|
24 | */ |
|
25 | public class RequestData extends XmlRpcHttpRequestConfigImpl { |
|
26 | private final Connection connection; |
|
27 | private boolean keepAlive; |
|
28 | private String method, httpVersion; |
|
29 | 175 | private int contentLength = -1; |
30 | private boolean success; |
|
31 | ||
32 | /** Creates a new instance. |
|
33 | * @param pConnection The connection, which is serving the request. |
|
34 | */ |
|
35 | 175 | public RequestData(Connection pConnection) { |
36 | 175 | connection = pConnection; |
37 | 175 | } |
38 | ||
39 | /** Returns the connection, which is serving the request. |
|
40 | * @return The request connection. |
|
41 | */ |
|
42 | 175 | public Connection getConnection() { return connection; } |
43 | ||
44 | /** Returns, whether HTTP keepAlive is enabled for this |
|
45 | * connection. |
|
46 | * @return True, if keepAlive is enabled, false otherwise. |
|
47 | */ |
|
48 | 525 | public boolean isKeepAlive() { return keepAlive; } |
49 | ||
50 | /** Sets, whether HTTP keepAlive is enabled for this |
|
51 | * connection. |
|
52 | * @param pKeepAlive True, if keepAlive is enabled, false otherwise. |
|
53 | */ |
|
54 | public void setKeepAlive(boolean pKeepAlive) { |
|
55 | 245 | keepAlive = pKeepAlive; |
56 | 245 | } |
57 | ||
58 | /** Returns the requests HTTP version. |
|
59 | * @return HTTP version, for example "1.0" |
|
60 | */ |
|
61 | 175 | public String getHttpVersion() { return httpVersion; } |
62 | ||
63 | /** Sets the requests HTTP version. |
|
64 | * @param pHttpVersion HTTP version, for example "1.0" |
|
65 | */ |
|
66 | public void setHttpVersion(String pHttpVersion) { |
|
67 | 175 | httpVersion = pHttpVersion; |
68 | 175 | } |
69 | ||
70 | /** Returns the requests content length. |
|
71 | * @return Content length, if known, or -1, if unknown. |
|
72 | */ |
|
73 | 175 | public int getContentLength() { return contentLength; } |
74 | ||
75 | /** Sets the requests content length. |
|
76 | * @param pContentLength Content length, if known, or -1, if unknown. |
|
77 | */ |
|
78 | public void setContentLength(int pContentLength) { |
|
79 | 151 | contentLength = pContentLength; |
80 | 151 | } |
81 | ||
82 | /** Returns, whether a byte array for buffering the output is |
|
83 | * required. |
|
84 | * @return True, if the byte array is required, false otherwise. |
|
85 | */ |
|
86 | public boolean isByteArrayRequired() { |
|
87 | 175 | return isKeepAlive() || !isEnabledForExtensions() || !isContentLengthOptional(); |
88 | } |
|
89 | ||
90 | /** Returns the request method. |
|
91 | * @return The request method, should be "POST". |
|
92 | */ |
|
93 | 0 | public String getMethod() { return method; } |
94 | ||
95 | /** Sets the request method. |
|
96 | * @param pMethod The request method, should be "POST". |
|
97 | */ |
|
98 | public void setMethod(String pMethod) { |
|
99 | 175 | method = pMethod; |
100 | 175 | } |
101 | ||
102 | /** Returns, whether the request was executed successfull. |
|
103 | * @return True for success, false, if an error occurred. |
|
104 | */ |
|
105 | 0 | public boolean isSuccess() { return success; } |
106 | ||
107 | /** Sets, whether the request was executed successfull. |
|
108 | * @param pSuccess True for success, false, if an error occurred. |
|
109 | */ |
|
110 | public void setSuccess(boolean pSuccess) { |
|
111 | 175 | success = pSuccess; |
112 | 175 | } |
113 | } |