You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by sa...@apache.org on 2005/09/12 10:34:43 UTC
svn commit: r280290 -
/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java
Author: saminda
Date: Mon Sep 12 01:34:39 2005
New Revision: 280290
URL: http://svn.apache.org/viewcvs?rev=280290&view=rev
Log:
Transportsender being updated to include chunking on/off facility.
Modified:
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java?rev=280290&r1=280289&r2=280290&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java Mon Sep 12 01:34:39 2005
@@ -246,15 +246,24 @@
public byte[] writeBytes() throws AxisFault {
try {
ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
- XMLStreamWriter outputWriter =
- XMLOutputFactory.newInstance().createXMLStreamWriter(
- bytesOut,
- charSetEnc);
- OMOutputImpl out = new OMOutputImpl(outputWriter);
- out.setCharSetEncoding(charSetEnc);
- element.serialize(out);
- out.flush();
- return bytesOut.toByteArray();
+
+ if (!doingMTOM) {
+ XMLStreamWriter outputWriter =
+ XMLOutputFactory.newInstance()
+ .createXMLStreamWriter(bytesOut,
+ charSetEnc);
+ OMOutputImpl output = new OMOutputImpl(outputWriter);
+ output.setCharSetEncoding(charSetEnc);
+ element.serialize(output);
+ output.flush();
+ return bytesOut.toByteArray();
+ } else {
+ omOutput.setCharSetEncoding(charSetEnc);
+ omOutput.setOutputStream(bytesOut, true); //changed...
+ element.serialize(omOutput);
+ omOutput.flush();
+ return bytesOut.toByteArray();
+ }
} catch (XMLStreamException e) {
throw new AxisFault(e);
} catch (FactoryConfigurationError e) {
@@ -262,20 +271,36 @@
}
}
+ private void handleOMOutput(OutputStream out, boolean doingMTOM)
+ throws XMLStreamException {
+ omOutput.setOutputStream(out, doingMTOM);
+ element.serialize(omOutput);
+ omOutput.flush();
+ }
+
public void writeRequest(OutputStream out) throws IOException {
try {
- if (chuncked || doingMTOM) {
- omOutput.setOutputStream(out, doingMTOM);
- element.serialize(omOutput);
- omOutput.flush();
+ if (doingMTOM) { //chagened ..
+ if (chuncked) {
+ this.handleOMOutput(out, doingMTOM);
+ } else {
+ if (bytes == null) {
+ bytes = writeBytes();
+ }
+ out.write(bytes);
+ }
} else {
- if (bytes == null) {
- bytes = writeBytes();
+ if (chuncked) {
+ this.handleOMOutput(out, doingMTOM);
+ } else {
+ if (bytes == null) {
+ bytes = writeBytes();
+ }
+ out.write(bytes);
}
- out.write(bytes);
}
- out.flush();
+ out.flush();
} catch (XMLStreamException e) {
throw new AxisFault(e);
} catch (FactoryConfigurationError e) {
@@ -286,18 +311,29 @@
}
public long getContentLength() {
- try {
- if (chuncked || doingMTOM) {
- return -1;
- } else {
- if (bytes == null) {
- bytes = writeBytes();
+ try {
+ if (doingMTOM) { //chagened
+ if (chuncked) {
+ return -1;
+ } else {
+ if (bytes == null) {
+ bytes = writeBytes();
+ }
+ return bytes.length;
+ }
+ } else {
+ if (chuncked) {
+ return -1;
+ } else {
+ if (bytes == null) {
+ bytes = writeBytes();
+ }
+ return bytes.length;
+ }
}
- return bytes.length;
+ } catch (AxisFault e) {
+ return -1;
}
- } catch (AxisFault e) {
- return -1;
- }
}
public String getContentType() {