You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-user@jakarta.apache.org by Yu Hong <yu...@isystech.com> on 2002/05/31 03:38:04 UTC

Response content issue!

Hi, Guys:
      Now, I try to get the whole response info after the test case be
handled, I know the class WebResponse can help me a lot, but actually
the methods getInputStream, getText, etc can only let me get the
response's content info, so how can I get the all response's header
info? through the HttpURLconnection which I can get  from the method
getConnection? But actually even in HttpURLConnection, there was not a
method can let you get the whole stuff, right?
      BTW, I found for WebResponse, if I use getInputStream to get the
info, then I will get an empty string when I try to use getText to get
the response content again, interesting:-)
      So, anyone have run into the same problem?

Any idea is appreciated, thank you very much!!!

Hong



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Response content issue!

Posted by Nicholas Lesiecki <ni...@eblox.com>.
Hong,

Your best bet is probably to use the version of WebResponse from HttpUnit,
which (if I recall correctly) has methods like:

public abstract java.lang.String getHeaderField(java.lang.String
fieldName)Returns the value for the specified header field. If no such field
is defined, will return null. If more than one header is defined for the
specified name, returns only the first found.

public abstract java.lang.String[] getHeaderFields(java.lang.String
fieldName)
Returns the values for the specified header field. If no such field is
defined, will return an empty array.

etc.

Does this answer your question?

For more info on httpunit integration, see:

http://jakarta.apache.org/cactus/howto_httpunit.html

Cheers,

Nick

-----Original Message-----
From: Yu Hong [mailto:yuhong@isystech.com]
Sent: Thursday, May 30, 2002 6:38 PM
To: cactus-user@jakarta.apache.org
Subject: Response content issue!


Hi, Guys:
      Now, I try to get the whole response info after the test case be
handled, I know the class WebResponse can help me a lot, but actually
the methods getInputStream, getText, etc can only let me get the
response's content info, so how can I get the all response's header
info? through the HttpURLconnection which I can get  from the method
getConnection? But actually even in HttpURLConnection, there was not a
method can let you get the whole stuff, right?
      BTW, I found for WebResponse, if I use getInputStream to get the
info, then I will get an empty string when I try to use getText to get
the response content again, interesting:-)
      So, anyone have run into the same problem?

Any idea is appreciated, thank you very much!!!

Hong



--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>