1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
package org.apache.xmlrpc.webserver; |
17 |
|
|
18 |
|
import java.io.IOException; |
19 |
|
import java.io.InputStream; |
20 |
|
import java.io.OutputStream; |
21 |
|
|
22 |
|
import org.apache.xmlrpc.XmlRpcException; |
23 |
|
import org.apache.xmlrpc.common.XmlRpcStreamRequestConfig; |
24 |
|
import org.apache.xmlrpc.server.XmlRpcStreamServer; |
25 |
|
|
26 |
|
|
27 |
154 |
class ConnectionServer extends XmlRpcStreamServer { |
28 |
|
protected void writeError(XmlRpcStreamRequestConfig pConfig, OutputStream pStream, |
29 |
|
Throwable pError) throws XmlRpcException { |
30 |
0 |
RequestData data = (RequestData) pConfig; |
31 |
|
try { |
32 |
0 |
if (data.isByteArrayRequired()) { |
33 |
0 |
super.writeError(pConfig, pStream, pError); |
34 |
0 |
data.getConnection().writeError(data, pError, pStream); |
35 |
|
} else { |
36 |
0 |
data.getConnection().writeErrorHeader(data, pError, -1); |
37 |
0 |
super.writeError(pConfig, pStream, pError); |
38 |
0 |
pStream.flush(); |
39 |
|
} |
40 |
0 |
} catch (IOException e) { |
41 |
0 |
throw new XmlRpcException(e.getMessage(), e); |
42 |
|
} |
43 |
0 |
} |
44 |
|
|
45 |
|
protected void writeResponse(XmlRpcStreamRequestConfig pConfig, OutputStream pStream, Object pResult) throws XmlRpcException { |
46 |
175 |
RequestData data = (RequestData) pConfig; |
47 |
|
try { |
48 |
175 |
if (data.isByteArrayRequired()) { |
49 |
105 |
super.writeResponse(pConfig, pStream, pResult); |
50 |
105 |
data.getConnection().writeResponse(data, pStream); |
51 |
|
} else { |
52 |
70 |
data.getConnection().writeResponseHeader(data, -1); |
53 |
70 |
super.writeResponse(pConfig, pStream, pResult); |
54 |
70 |
pStream.flush(); |
55 |
|
} |
56 |
0 |
} catch (IOException e) { |
57 |
0 |
throw new XmlRpcException(e.getMessage(), e); |
58 |
|
} |
59 |
175 |
} |
60 |
|
|
61 |
|
protected InputStream newInputStream(XmlRpcStreamRequestConfig pConfig, Object pConnection) throws IOException { |
62 |
175 |
return ((Connection) pConnection).getInputStream((RequestData) pConfig); |
63 |
|
} |
64 |
|
|
65 |
|
protected OutputStream newOutputStream(XmlRpcStreamRequestConfig pConfig, Object pConnection) throws IOException { |
66 |
175 |
return ((Connection) pConnection).getOutputStream(pConfig); |
67 |
|
} |
68 |
|
|
69 |
|
protected void closeConnection(Object pConnection) throws IOException { |
70 |
175 |
} |
71 |
|
} |