: tmpURL.getFile()));
}
Message reqMessage = msgContext.getRequestMessage();
boolean http10 = true; //True if this is to use HTTP 1.0 / false HTTP 1.1
boolean httpChunkStream = false; //Use HTTP chunking or not.
boolean httpContinueExpected = false; //Under HTTP 1.1 if false you *MAY* need to wait for a 100 rc,
// if true the server MUST reply with 100 continue.
String httpConnection = null;
String httpver = msgContext.getStrProp(MessageContext.HTTP_TRANSPORT_VERSION);
if (null == httpver) httpver = HTTPConstants.HEADER_PROTOCOL_V10;
httpver = httpver.trim();
if (httpver.equals(HTTPConstants.HEADER_PROTOCOL_V11)) {
http10 = false;
}
//process user defined headers for information.
Hashtable userHeaderTable = (Hashtable) msgContext.
getProperty(HTTPConstants.REQUEST_HEADERS);
if (userHeaderTable != null) {
if (null == otherHeaders) otherHeaders = new StringBuffer(1024);
for (java.util.Iterator e = userHeaderTable.entrySet().iterator();
e.hasNext();) {
java.util.Map.Entry me = (java.util.Map.Entry) e.next();
Object keyObj = me.getKey();
if (null == keyObj) continue;
String key = keyObj.toString().trim();
if (key.equalsIgnoreCase(HTTPConstants.HEADER_TRANSFER_ENCODING)) {
if (!http10) {
String val = me.getValue().toString();
if (null != val && val.trim().equalsIgnoreCase(HTTPConstants.HEADER_TRANSFER_ENCODING_CHUNKED))
httpChunkStream = true;
}
} else if (key.equalsIgnoreCase(HTTPConstants.HEADER_HOST)) {
//ignore
} else if (key.equalsIgnoreCase(HTTPConstants.HEADER_CONTENT_TYPE)) {
//ignore
} else if (key.equalsIgnoreCase(HTTPConstants.HEADER_SOAP_ACTION)) {
//ignore
} else if (key.equalsIgnoreCase(HTTPConstants.HEADER_CONTENT_LENGTH)) {
//ignore
} else if (key.equalsIgnoreCase(HTTPConstants.HEADER_COOKIE)) {
//ignore
} else if (key.equalsIgnoreCase(HTTPConstants.HEADER_COOKIE2)) {
//ignore
} else if (key.equalsIgnoreCase(HTTPConstants.HEADER_AUTHORIZATION)) {
//ignore
} else if (key.equalsIgnoreCase(HTTPConstants.HEADER_PROXY_AUTHORIZATION)) {
//ignore
} else if (key.equalsIgnoreCase(HTTPConstants.HEADER_CONNECTION)) {
if (!http10) {
String val = me.getValue().toString();
if (val.trim().equalsIgnoreCase(HTTPConstants.HEADER_CONNECTION_CLOSE))
httpConnection = HTTPConstants.HEADER_CONNECTION_CLOSE;
}
//HTTP 1.0 will always close.
//HTTP 1.1 will use persistent. //no need to specify
} else {
if( !http10 && key.equalsIgnoreCase(HTTPConstants.HEADER_EXPECT)) {
String val = me.getValue().toString();
if (null != val && val.trim().equalsIgnoreCase(HTTPConstants.HEADER_EXPECT_100_Continue))
httpContinueExpected = true;
}
otherHeaders.append(key).append(": ").append(me.getValue()).append("\r\n");
}
}
}
if (!http10)
httpConnection = HTTPConstants.HEADER_CONNECTION_CLOSE; //Force close for now.
header.append(" ");
header.append(http10 ? HTTPConstants.HEADER_PROTOCOL_10 :
HTTPConstants.HEADER_PROTOCOL_11)
.append("\r\n")
.append(HTTPConstants.HEADER_CONTENT_TYPE)
.append(": ")
.append(reqMessage.getContentType(msgContext.getSOAPConstants()))
.append("\r\n")
.append( HTTPConstants.HEADER_ACCEPT ) //Limit to the types that are meaningful to us.
.append( ": ")
.append( HTTPConstants.HEADER_ACCEPT_APPL_SOAP)
.append( ", ")
.append( HTTPConstants.HEADER_ACCEPT_APPLICATION_DIME)
.append( ", ")
.append( HTTPConstants.HEADER_ACCEPT_MULTIPART_RELATED)
.append( ", ")
.append( HTTPConstants.HEADER_ACCEPT_TEXT_ALL)
.append("\r\n")
.append(HTTPConstants.HEADER_USER_AGENT) //Tell who we are.
.append( ": ")
.append(Constants.AXIS_VERSION)
.append("\r\n")
.append(HTTPConstants.HEADER_HOST) //used for virtual connections
.append(": ")
.append(host)
.append((port == -1)?(""):(":" + port))
.append("\r\n")
.append(HTTPConstants.HEADER_CACHE_CONTROL) //Stop caching proxies from caching SOAP reqeuest.
.append(": ")
.append(HTTPConstants.HEADER_CACHE_CONTROL_NOCACHE)
.append("\r\n")
.append(HTTPConstants.HEADER_PRAGMA)
.append(": ")
.append(HTTPConstants.HEADER_CACHE_CONTROL_NOCACHE)
.append("\r\n")
.append(HTTPConstants.HEADER_SOAP_ACTION) //The SOAP action.
.append(": \"")
.append(action)
.append("\"\r\n");
if (!httpChunkStream) {
//Content length MUST be sent on HTTP 1.0 requests.
header.append(HTTPConstants.HEADER_CONTENT_LENGTH)
.append(": ")
.append(reqMessage.getContentLength())
.append("\r\n");
} else {
//Do http chunking.
header.append(HTTPConstants.HEADER_TRANSFER_ENCODING)
.append(": ")
.append(HTTPConstants.HEADER_TRANSFER_ENCODING_CHUNKED)
.append("\r\n");
}
if (null != httpConnection) {
header.append(HTTPConstants.HEADER_CONNECTION);
header.append(": ");
header.append(httpConnection);
header.append("\r\n");
}
if (null != otherHeaders)
header.append(otherHeaders); //Add other headers to the end.
header.append("\r\n"); //The empty line to start the BODY.
OutputStream out = sock.getOutputStream();
if (httpChunkStream) {
out.write(header.toString()
.getBytes(HTTPConstants.HEADER_DEFAULT_CHAR_ENCODING));
if(httpContinueExpected ){ //We need to get a reply from the server as to whether
// it wants us send anything more.
out.flush();
Hashtable cheaders= new Hashtable ();
inp=readFromSocket(sock, msgContext, null, cheaders);
int returnCode= -1;
Integer Irc= (Integer)msgContext.getProperty(HTTPConstants.MC_HTTP_STATUS_CODE);
if(null != Irc) returnCode= Irc.intValue();
if(100 == returnCode){ // got 100 we may continue.
//Need todo a little msgContext house keeping....
msgContext.removeProperty(HTTPConstants.MC_HTTP_STATUS_CODE);
msgContext.removeProperty(HTTPConstants.MC_HTTP_STATUS_MESSAGE);
}
else{ //If no 100 Continue then we must not send anything!
String statusMessage= (String)
msgContext.getProperty(HTTPConstants.MC_HTTP_STATUS_MESSAGE);
AxisFault fault = new AxisFault("HTTP", "(" + returnCode+ ")" + statusMessage, null, null);
fault.setFaultDetailString(Messages.getMessage("return01",
"" + returnCode, ""));
throw fault;
}
}
ChunkedOutputStream chunkedOutputStream = new ChunkedOutputStream(out);
out = new BufferedOutputStream(chunkedOutputStream, 8 * 1024);
try {
reqMessage.writeTo(out);
} catch (SOAPException e) {
log.error(Messages.getMessage("exception00"), e);
}
out.flush();
chunkedOutputStream.eos();
} else {
//No chunking...
if(httpContinueExpected ){ //We need to get a reply from the server as to whether
// it wants us send anything more.
out.flush();
Hashtable cheaders= new Hashtable ();
inp=readFromSocket(sock, msgContext, null, cheaders);
int returnCode= -1;
Integer Irc= (Integer) msgContext.getProperty(HTTPConstants.MC_HTTP_STATUS_CODE);
if(null != Irc) returnCode= Irc.intValue();
if(100 == returnCode){ // got 100 we may continue.
//Need todo a little msgContext house keeping....
msgContext.setProperty(HTTPConstants.MC_HTTP_STATUS_CODE,
null);
msgContext.setProperty(HTTPConstants.MC_HTTP_STATUS_MESSAGE,
null);
}
else{ //If no 100 Continue then we must not send anything!
String statusMessage= (String)
msgContext.getProperty(HTTPConstants.MC_HTTP_STATUS_MESSAGE);
AxisFault fault = new AxisFault("HTTP", "(" + returnCode+ ")" + statusMessage, null, null);
fault.setFaultDetailString(Messages.getMessage("return01",
"" + returnCode, ""));
throw fault;
}
}
out = new BufferedOutputStream(out, 8 * 1024);
try {
out.write(header.toString()
.getBytes(HTTPConstants.HEADER_DEFAULT_CHAR_ENCODING));
reqMessage.writeTo(out);
} catch (SOAPException e) {
log.error(Messages.getMessage("exception00"), e);
}
// Flush ONLY once.
out.flush();