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 to...@apache.org on 2003/10/15 11:37:45 UTC
cvs commit: ws-axis/java/src/org/apache/axis/transport/http HTTPSender.java
toshi 2003/10/15 02:37:45
Modified: java/src/org/apache/axis/transport/http HTTPSender.java
Log:
Fix for the bug http://nagoya.apache.org/bugzilla/long_list.cgi?buglist=23830.
Revision Changes Path
1.99 +23 -23 ws-axis/java/src/org/apache/axis/transport/http/HTTPSender.java
Index: HTTPSender.java
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/transport/http/HTTPSender.java,v
retrieving revision 1.98
retrieving revision 1.99
diff -u -r1.98 -r1.99
--- HTTPSender.java 6 Oct 2003 19:49:25 -0000 1.98
+++ HTTPSender.java 15 Oct 2003 09:37:44 -0000 1.99
@@ -238,7 +238,7 @@
.append(cookie2).append("\r\n");
}
}
-
+
StringBuffer header = new StringBuffer();
String webMethod = null;
@@ -254,7 +254,7 @@
} else {
posting = webMethod.equals(HTTPConstants.HEADER_POST);
}
-
+
header.append(webMethod).append(" ");
if (useFullURL.value) {
header.append(tmpURL.toExternalForm());
@@ -404,7 +404,7 @@
.append("\r\n");
}
}
-
+
if (null != httpConnection) {
header.append(HTTPConstants.HEADER_CONNECTION);
header.append(": ");
@@ -416,28 +416,28 @@
//Add other headers to the end.
//for pre java1.4 support, we have to turn the string buffer argument into
//a string before appending.
- header.append(otherHeaders.toString());
+ header.append(otherHeaders.toString());
}
header.append("\r\n"); //The empty line to start the BODY.
OutputStream out = sock.getOutputStream();
-
+
if (!posting) {
out.write(header.toString()
.getBytes(HTTPConstants.HEADER_DEFAULT_CHAR_ENCODING));
out.flush();
return null;
}
-
+
InputStream inp = null;
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();
@@ -456,9 +456,9 @@
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;
@@ -491,14 +491,14 @@
log.debug("---------------------------------------------------");
log.debug(header + reqEnv);
}
-
+
return inp;
}
-
+
private InputStream readHeadersFromSocket(Socket sock,
MessageContext msgContext,
InputStream inp,
- Hashtable headers)
+ Hashtable headers)
throws IOException {
byte b = 0;
int len = 0;
@@ -508,7 +508,7 @@
if(null == inp) {
inp = new BufferedInputStream(sock.getInputStream());
}
-
+
if (headers == null) {
headers = new Hashtable();
}
@@ -590,7 +590,7 @@
len = 0;
}
}
-
+
return inp;
}
@@ -609,7 +609,7 @@
throws IOException {
Message outMsg = null;
byte b;
-
+
Integer rc = (Integer)msgContext.getProperty(
HTTPConstants.MC_HTTP_STATUS_CODE);
int returnCode = 0;
@@ -659,29 +659,29 @@
String contentLocation =
(String) headers
.get(HTTPConstants.HEADER_CONTENT_LOCATION.toLowerCase());
-
+
contentLocation = (null == contentLocation)
? null
: contentLocation.trim();
-
+
String contentLength =
(String) headers
.get(HTTPConstants.HEADER_CONTENT_LENGTH.toLowerCase());
-
+
contentLength = (null == contentLength)
? null
: contentLength.trim();
-
+
String transferEncoding =
- (String) headers
- .get(HTTPConstants.HEADER_TRANSFER_ENCODING.toLowerCase());
+ ((String) headers
+ .get(HTTPConstants.HEADER_TRANSFER_ENCODING)).toLowerCase();
if (null != transferEncoding
&& transferEncoding.trim()
.equals(HTTPConstants.HEADER_TRANSFER_ENCODING_CHUNKED)) {
inp = new ChunkedInputStream(inp);
}
-
-
+
+
outMsg = new Message( new SocketInputStream(inp, sock), false,
contentType, contentLocation);
outMsg.setMessageType(Message.RESPONSE);
Re: cvs commit: ws-axis/java/src/org/apache/axis/transport/http
HTTPSender.java
Posted by Toshiyuki Kimura <to...@apache.org>.
Thanks for the comments - Steve,
On Wed, 15 Oct 2003, Steve Loughran wrote:
> toshi@apache.org wrote:
> > toshi 2003/10/15 02:37:45
> >
> > Modified: java/src/org/apache/axis/transport/http HTTPSender.java
> > Log:
> > Fix for the bug http://nagoya.apache.org/bugzilla/long_list.cgi?buglist=23830.
> >
>
> .equalsIgnoreCase() is the other option here; Java Performance
> Tuning is undecided as to whether the costs of creating a new
> string object and a case sensitive equals beats a case
> insensitive equality test.
Yah. And this code also has a few ConstantsValue.toLowerCase().
I need to verify again - maybe tomorrow.
--
Toshi <to...@apache.org>
Re: cvs commit: ws-axis/java/src/org/apache/axis/transport/http HTTPSender.java
Posted by Steve Loughran <st...@iseran.com>.
toshi@apache.org wrote:
> toshi 2003/10/15 02:37:45
>
> Modified: java/src/org/apache/axis/transport/http HTTPSender.java
> Log:
> Fix for the bug http://nagoya.apache.org/bugzilla/long_list.cgi?buglist=23830.
>
> @@ -659,29 +659,29 @@
> String contentLocation =
> (String) headers
> .get(HTTPConstants.HEADER_CONTENT_LOCATION.toLowerCase());
this could be the same defect, perhaps?
> -
> +
> contentLocation = (null == contentLocation)
> ? null
> : contentLocation.trim();
> -
> +
> String contentLength =
> (String) headers
> .get(HTTPConstants.HEADER_CONTENT_LENGTH.toLowerCase());
and again
> if (null != transferEncoding
> && transferEncoding.trim()
> .equals(HTTPConstants.HEADER_TRANSFER_ENCODING_CHUNKED)) {
.equalsIgnoreCase() is the other option here; Java Performance Tuning is
undecided as to whether the costs of creating a new string object and a
case sensitive equals beats a case insensitive equality test.
Re: cvs commit: ws-axis/java/src/org/apache/axis/transport/http
HTTPSender.java
Posted by Toshiro Takase <E3...@jp.ibm.com>.
Hi, Toshi,
# Please call me Toshiro :)
I am sorry for lack of my explanation.
My point is ,,,
HTTPConstants.HEADER_TRANSFER_ENCODING (="Transfer-Encoding")
HTTPConstants.HEADER_TRANSFER_ENCODING_CHUNKED (="chunked")
Your fix changes the behavior of the former, header name, doesn't it?
I think your intention is the latter, header value, "chunked".
Thanks in advance,
Toshiro TAKASE
IBM Research, Tokyo Research Laboratory, Internet Technology
notes ID: Toshiro Takase/Japan/IBM@IBMJP, e-mail: E30809@jp.ibm.com
|---------+---------------------------->
| | Toshiyuki Kimura |
| | <toshi@apache.org|
| | > |
| | |
| | 2003/10/15 22:43 |
| | Please respond to|
| | axis-dev |
|---------+---------------------------->
>-------------------------------------------------------------------------------------------------------------------------------------------|
| |
| To: axis-dev@ws.apache.org |
| cc: |
| Subject: Re: cvs commit: ws-axis/java/src/org/apache/axis/transport/http HTTPSender.java |
| |
| |
>-------------------------------------------------------------------------------------------------------------------------------------------|
Hello Takase-san,
Thanks for your rapid action.
My comments are in-line;
On Wed, 15 Oct 2003, Toshiro Takase wrote:
>
> Hello, toshi,
>
> In my humble opinion, you should have fixed Line:680 .equals
> .equalsIgnoreCase ,,,
Sure, I also think there're two ways. One is
the use of equalsIgnoreCase(), and the other is
toLowerCase() and equls(). I'd found the using
of equalsIgnoreCase in the same source, before
I applied the patch.
But I gave preference to toLowerCase() over
equalsIgnoreCase() at this time, because it seems
HTTPConstants.HEADER_TRANSFER_ENCODING.toLowerCase()
is not meaningful. However - now, I agreed with you.
Do you know why the original contributor doesn't
define the keys in HTTPConstants ? i.e. I think
the Constants.toLowerCase() is not exactly happy.
> ----------
> String transferEncoding =
> (String) headers
>
.get(HTTPConstants.HEADER_TRANSFER_ENCODING.toLowerCase());
> if (null != transferEncoding
> && transferEncoding.trim()
> - .equals(HTTPConstants.HEADER_TRANSFER_ENCODING_CHUNKED))
{
> +
> .equalsIgnoreCase(HTTPConstants.HEADER_TRANSFER_ENCODING_CHUNKED)) {
> inp = new ChunkedInputStream(inp);
> }
> ----------
--
Toshi <to...@apache.org>
Re: cvs commit: ws-axis/java/src/org/apache/axis/transport/http
HTTPSender.java
Posted by Toshiyuki Kimura <to...@apache.org>.
Hello Takase-san,
Thanks for your rapid action.
My comments are in-line;
On Wed, 15 Oct 2003, Toshiro Takase wrote:
>
> Hello, toshi,
>
> In my humble opinion, you should have fixed Line:680 .equals
> .equalsIgnoreCase ,,,
Sure, I also think there're two ways. One is
the use of equalsIgnoreCase(), and the other is
toLowerCase() and equls(). I'd found the using
of equalsIgnoreCase in the same source, before
I applied the patch.
But I gave preference to toLowerCase() over
equalsIgnoreCase() at this time, because it seems
HTTPConstants.HEADER_TRANSFER_ENCODING.toLowerCase()
is not meaningful. However - now, I agreed with you.
Do you know why the original contributor doesn't
define the keys in HTTPConstants ? i.e. I think
the Constants.toLowerCase() is not exactly happy.
> ----------
> String transferEncoding =
> (String) headers
> .get(HTTPConstants.HEADER_TRANSFER_ENCODING.toLowerCase());
> if (null != transferEncoding
> && transferEncoding.trim()
> - .equals(HTTPConstants.HEADER_TRANSFER_ENCODING_CHUNKED)) {
> +
> .equalsIgnoreCase(HTTPConstants.HEADER_TRANSFER_ENCODING_CHUNKED)) {
> inp = new ChunkedInputStream(inp);
> }
> ----------
--
Toshi <to...@apache.org>
Re: cvs commit: ws-axis/java/src/org/apache/axis/transport/http
HTTPSender.java
Posted by Toshiro Takase <E3...@jp.ibm.com>.
Hello, toshi,
In my humble opinion, you should have fixed Line:680 .equals ->
.equalsIgnoreCase ,,,
----------
String transferEncoding =
(String) headers
.get(HTTPConstants.HEADER_TRANSFER_ENCODING.toLowerCase());
if (null != transferEncoding
&& transferEncoding.trim()
- .equals(HTTPConstants.HEADER_TRANSFER_ENCODING_CHUNKED)) {
+
.equalsIgnoreCase(HTTPConstants.HEADER_TRANSFER_ENCODING_CHUNKED)) {
inp = new ChunkedInputStream(inp);
}
----------
The position of .toLowerCase() was right, I think.
HTTP Header name is set in readHeadersFromSocket method as follows,
----------
headers.put(name.toLowerCase(), value);
----------
Thanks in advance,
Toshiro TAKASE
IBM Research, Tokyo Research Laboratory, Internet Technology
notes ID: Toshiro Takase/Japan/IBM@IBMJP, e-mail: E30809@jp.ibm.com
|---------+---------------------------->
| | toshi@apache.org |
| | |
| | 2003/10/15 18:37 |
| | Please respond to|
| | axis-dev |
|---------+---------------------------->
>-------------------------------------------------------------------------------------------------------------------------------------------|
| |
| To: ws-axis-cvs@apache.org |
| cc: |
| Subject: cvs commit: ws-axis/java/src/org/apache/axis/transport/http HTTPSender.java |
| |
| |
>-------------------------------------------------------------------------------------------------------------------------------------------|
toshi 2003/10/15 02:37:45
Modified: java/src/org/apache/axis/transport/http HTTPSender.java
Log:
Fix for the bug
http://nagoya.apache.org/bugzilla/long_list.cgi?buglist=23830.
Revision Changes Path
1.99 +23 -23
ws-axis/java/src/org/apache/axis/transport/http/HTTPSender.java
Index: HTTPSender.java
===================================================================
RCS file:
/home/cvs/ws-axis/java/src/org/apache/axis/transport/http/HTTPSender.java,v
retrieving revision 1.98
retrieving revision 1.99
diff -u -r1.98 -r1.99
--- HTTPSender.java 6 Oct 2003 19:49:25 -0000 1.98
+++ HTTPSender.java 15 Oct 2003 09:37:44 -0000 1.99
@@ -238,7 +238,7 @@
.append(cookie2).append("\r\n");
}
}
-
+
StringBuffer header = new StringBuffer();
String webMethod = null;
@@ -254,7 +254,7 @@
} else {
posting = webMethod.equals(HTTPConstants.HEADER_POST);
}
-
+
header.append(webMethod).append(" ");
if (useFullURL.value) {
header.append(tmpURL.toExternalForm());
@@ -404,7 +404,7 @@
.append("\r\n");
}
}
-
+
if (null != httpConnection) {
header.append(HTTPConstants.HEADER_CONNECTION);
header.append(": ");
@@ -416,28 +416,28 @@
//Add other headers to the end.
//for pre java1.4 support, we have to turn the string buffer
argument into
//a string before appending.
- header.append(otherHeaders.toString());
+ header.append(otherHeaders.toString());
}
header.append("\r\n"); //The empty line to start the BODY.
OutputStream out = sock.getOutputStream();
-
+
if (!posting) {
out.write(header.toString()
.getBytes(HTTPConstants.HEADER_DEFAULT_CHAR_ENCODING));
out.flush();
return null;
}
-
+
InputStream inp = null;
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();
@@ -456,9 +456,9 @@
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;
@@ -491,14 +491,14 @@
log.debug("---------------------------------------------------");
log.debug(header + reqEnv);
}
-
+
return inp;
}
-
+
private InputStream readHeadersFromSocket(Socket sock,
MessageContext msgContext,
InputStream inp,
- Hashtable headers)
+ Hashtable headers)
throws IOException {
byte b = 0;
int len = 0;
@@ -508,7 +508,7 @@
if(null == inp) {
inp = new BufferedInputStream(sock.getInputStream());
}
-
+
if (headers == null) {
headers = new Hashtable();
}
@@ -590,7 +590,7 @@
len = 0;
}
}
-
+
return inp;
}
@@ -609,7 +609,7 @@
throws IOException {
Message outMsg = null;
byte b;
-
+
Integer rc = (Integer)msgContext.getProperty(
HTTPConstants.MC_HTTP_STATUS_CODE);
int returnCode = 0;
@@ -659,29 +659,29 @@
String contentLocation =
(String) headers
.get(HTTPConstants.HEADER_CONTENT_LOCATION.toLowerCase());
-
+
contentLocation = (null == contentLocation)
? null
: contentLocation.trim();
-
+
String contentLength =
(String) headers
.get(HTTPConstants.HEADER_CONTENT_LENGTH.toLowerCase());
-
+
contentLength = (null == contentLength)
? null
: contentLength.trim();
-
+
String transferEncoding =
- (String) headers
-
.get(HTTPConstants.HEADER_TRANSFER_ENCODING.toLowerCase());
+ ((String) headers
+
.get(HTTPConstants.HEADER_TRANSFER_ENCODING)).toLowerCase();
if (null != transferEncoding
&& transferEncoding.trim()
.equals(HTTPConstants.HEADER_TRANSFER_ENCODING_CHUNKED))
{
inp = new ChunkedInputStream(inp);
}
-
-
+
+
outMsg = new Message( new SocketInputStream(inp, sock), false,
contentType, contentLocation);
outMsg.setMessageType(Message.RESPONSE);