Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 package org.apache.xmlrpc.webserver;
00020
00021 import java.io.ByteArrayOutputStream;
00022 import java.io.IOException;
00023 import java.io.OutputStream;
00024
00025 import org.apache.xmlrpc.XmlRpcException;
00026 import org.apache.xmlrpc.common.ServerStreamConnection;
00027 import org.apache.xmlrpc.common.XmlRpcStreamRequestConfig;
00028 import org.apache.xmlrpc.server.XmlRpcHttpServer;
00029
00030
00031 class ConnectionServer extends XmlRpcHttpServer {
00032 protected void writeError(XmlRpcStreamRequestConfig pConfig, OutputStream pStream,
00033 Throwable pError) throws XmlRpcException {
00034 RequestData data = (RequestData) pConfig;
00035 try {
00036 if (data.isByteArrayRequired()) {
00037 super.writeError(pConfig, pStream, pError);
00038 data.getConnection().writeError(data, pError, (ByteArrayOutputStream) pStream);
00039 } else {
00040 data.getConnection().writeErrorHeader(data, pError, -1);
00041 super.writeError(pConfig, pStream, pError);
00042 pStream.flush();
00043 }
00044 } catch (IOException e) {
00045 throw new XmlRpcException(e.getMessage(), e);
00046 }
00047 }
00048
00049 protected void writeResponse(XmlRpcStreamRequestConfig pConfig, OutputStream pStream, Object pResult) throws XmlRpcException {
00050 RequestData data = (RequestData) pConfig;
00051 try {
00052 if (data.isByteArrayRequired()) {
00053 super.writeResponse(pConfig, pStream, pResult);
00054 data.getConnection().writeResponse(data, pStream);
00055 } else {
00056 data.getConnection().writeResponseHeader(data, -1);
00057 super.writeResponse(pConfig, pStream, pResult);
00058 pStream.flush();
00059 }
00060 } catch (IOException e) {
00061 throw new XmlRpcException(e.getMessage(), e);
00062 }
00063 }
00064
00065 protected void setResponseHeader(ServerStreamConnection pConnection, String pHeader, String pValue) {
00066 ((Connection) pConnection).setResponseHeader(pHeader, pValue);
00067 }
00068 }