On Fri, 2007-07-27 at 10:24 +0200, Roland Weber wrote: > Hello Jeroen, > > > I need a tool (HttpClient?) to parse a String representation of a > > request and a response like exampled below into an object > > representation, so not actually perform the request (or response). > > Please have a look at HttpCore (HttpComponents-Core base module): > http://jakarta.apache.org/httpcomponents/httpcomponents-core/ > http://jakarta.apache.org/httpcomponents/httpcomponents-core/httpcore/apidocs/index.html > > It has separate parser components. You can either try to use > the parser components directly, or you can implement a fake > "connection" that works only for receiving and uses the string > representations instead of opening a socket. > > While it has stabilized recently, the core API is still alpha. > If you find roadblocks for your use case, you can suggest > changes to the API. > > hope that helps, > Roland >
Jeroen, There are plenty of test cases in HttpCore that make use of mock HTTP connections (bound to a file or an array of bytes instead of a socket) to exercise HTTP message parsing code. You could use those as a starting point: http://svn.apache.org/repos/asf/jakarta/httpcomponents/httpcore/trunk/module-main/src/test/java/org/apache/http/impl/io/TestChunkCoding.java This is what you have to do: (1) Extend AbstractHttpDataReceiver and AbstractHttpDataTransmitter classes and make the super classes capable of receiving / transmitting data from / to a file or any other arbitrary data stream: http://jakarta.apache.org/httpcomponents/httpcomponents-core/httpcore/xref/org/apache/http/impl/io/AbstractHttpDataReceiver.html http://jakarta.apache.org/httpcomponents/httpcomponents-core/httpcore/xref/org/apache/http/impl/io/AbstractHttpDataTransmitter.html (2) Extend AbstractHttpClientConnection class and make the super class use your custom HTTP data transmitter and receiver. http://jakarta.apache.org/httpcomponents/httpcomponents-core/httpcore/xref/org/apache/http/impl/AbstractHttpClientConnection.html That is it Oleg --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
