*) Soap-handler: bugfix. wrong content-length was send when using content-encoding

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2877 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
theli 19 years ago
parent d3431433b0
commit ee4d4e8567

@ -466,6 +466,8 @@ public final class httpdSoapHandler extends httpdAbstractHandler implements http
Message soapErrorMsg = null; Message soapErrorMsg = null;
if (!conProp.containsKey(httpHeader.CONNECTION_PROP_PROXY_RESPOND_HEADER)) { if (!conProp.containsKey(httpHeader.CONNECTION_PROP_PROXY_RESPOND_HEADER)) {
// if no header was send until now we can send back an error message
SoapException soapEx = null; SoapException soapEx = null;
if (!(e instanceof SoapException)) { if (!(e instanceof SoapException)) {
soapEx = new SoapException(500,"internal server error",e); soapEx = new SoapException(500,"internal server error",e);
@ -481,8 +483,10 @@ public final class httpdSoapHandler extends httpdAbstractHandler implements http
this.theLogger.logSevere("Unexpected Exception while sending data to client",e); this.theLogger.logSevere("Unexpected Exception while sending data to client",e);
} }
} catch (Exception ex) { } catch (Exception ex) {
// the http response header was already send. Just log the error
this.theLogger.logSevere("Unexpected Exception while sending error message",e); this.theLogger.logSevere("Unexpected Exception while sending error message",e);
} finally { } finally {
// force connection close
conProp.setProperty(httpHeader.CONNECTION_PROP_PERSISTENT,"close"); conProp.setProperty(httpHeader.CONNECTION_PROP_PERSISTENT,"close");
} }
} }
@ -640,29 +644,6 @@ public final class httpdSoapHandler extends httpdAbstractHandler implements http
return result; return result;
} }
// protected void sendException(Properties conProp, OutputStream out, Exception e) throws UnsupportedEncodingException, IOException, SOAPException {
//
// Message soapErrorMsg = null;
// if (e instanceof SoapException) {
// Object errorMsg = ((SoapException)e).getErrorMsg();
// String contentType = null;
//
// // getting the error message body and content length
// ByteArrayOutputStream bout = new ByteArrayOutputStream();
// if (errorMsg instanceof String) {
// bout.write(((String)errorMsg).getBytes("UTF-8"));
// contentType = "text/plain; charset=UTF-8";
// } else {
// Message soapErrorMsg = (Message)errorMsg;
// soapErrorMsg.writeTo(bout);
// contentType = soapErrorMsg.getContentType(soapErrorMsg.getMessageContext().getSOAPConstants());
// }
// }
//
// // send out the message
// sendMessage(conProp, out, e.getStatusCode(), e.getStatusText(), contentType, bout.toByteArray());
// }
protected void sendMessage(Properties conProp, httpHeader requestHeader, OutputStream out, int statusCode, String statusText, String contentType, byte[] MessageBody) throws IOException { protected void sendMessage(Properties conProp, httpHeader requestHeader, OutputStream out, int statusCode, String statusText, String contentType, byte[] MessageBody) throws IOException {
// write out the response header // write out the response header
respondHeader(conProp, out, statusCode, statusText, (MessageBody==null)?null:contentType, (MessageBody==null)?-1:MessageBody.length, null, null); respondHeader(conProp, out, statusCode, statusText, (MessageBody==null)?null:contentType, (MessageBody==null)?-1:MessageBody.length, null, null);
@ -677,7 +658,7 @@ public final class httpdSoapHandler extends httpdAbstractHandler implements http
GZIPOutputStream gzipOut = null; GZIPOutputStream gzipOut = null;
OutputStream bodyOut = out; OutputStream bodyOut = out;
// getting the content type // getting the content type of the response
String contentType = soapMessage.getContentType(soapMessage.getMessageContext().getSOAPConstants()); String contentType = soapMessage.getContentType(soapMessage.getMessageContext().getSOAPConstants());
// getting the content length // getting the content length
@ -686,12 +667,22 @@ public final class httpdSoapHandler extends httpdAbstractHandler implements http
long contentLength = -1; long contentLength = -1;
if (httpHeader.supportChunkedEncoding(conProp)) { if (httpHeader.supportChunkedEncoding(conProp)) {
// we use chunked transfer encoding
transferEncoding = "chunked"; transferEncoding = "chunked";
} else { } else {
contentLength = soapMessage.getContentLength(); contentLength = soapMessage.getContentLength();
} }
if (requestHeader.acceptGzip()) { if (requestHeader.acceptGzip()) {
// send the response gzip encoded
contentEncoding = "gzip"; contentEncoding = "gzip";
// we don't know the content length of the compressed body
contentLength = -1;
// if chunked transfer encoding is not used we need to close the connection
if (!transferEncoding.equals("chunked")) {
conProp.setProperty(httpHeader.CONNECTION_PROP_PERSISTENT,"close");
}
} }
// sending the soap header // sending the soap header

Loading…
Cancel
Save