Beispiel #1
0
 /**
  * Constructs a new {@link HttpResponse} containing the given XML-RPC method response.
  *
  * <p>This implementation encodes the response using <code>UTF-8</code>, sets the status code to
  * <code>200</code>, and sets <code>Content-Type</code> header to <code>text/xml</code> as
  * required. No other headers are set.
  *
  * @param methodRsp The XML-RPC method response to be returned in the HTTP response.
  * @param encoding An {@link Encoding} describing the encoding to use when constructing this
  *     message. This also informs the <code>Content-Encoding</code> header value. May be <code>
  *     null</code>.
  * @return A new {@link HttpResponse} with the marshalled XML-RPC response as its content.
  * @throws IOException if an error occurs while marshalling the XML-RPC response.
  * @throws MarshallingException
  */
 protected HttpResponse toHttpResponse(
     HttpMessageBuffer origMsg, RpcResponse methodRsp, Encoding encoding)
     throws IOException, MarshallingException {
   ByteArrayOutputStream byteOs = new ByteArrayOutputStream();
   methodRsp.marshal(byteOs, Charset.forName("UTF-8"));
   byte[] rspXml = byteOs.toByteArray();
   HttpResponse httpRsp = this.newHttpResponse(origMsg, 200, "OK", encoding);
   httpRsp.addHeader(HttpConstants.Headers.CONTENT_TYPE, methodRsp.getContentType());
   httpRsp.setContent(rspXml);
   return httpRsp;
 }