RWIHttpAgent is deprecated and has been replaced by RWHttpAgent. Migrating to RWHttpAgent requires moving variables and removing lines of code.
RWHttpAgent returns more information with the request than RWIHttpAgent:
RWIHttpAgent returns only the body of the message -- any associated header and status information is lost (such as whether the request succeeded or failed).
RWHttpAgent returns an RWHttpReply, so header and status information are available.
For more information about RWHttpAgent, see Section 5.3, "Using the HTTP Classes," Section 5.4, "Advanced Topics," and the Internet Protocols Module Reference Guide.
The following examples show the differences between using RWIHttpAgent and RWHttpAgent. Example 32 requests the root document of the www.roguewave.com Web site using RWIHttpAgent.
RWIHttpVersion_1_0 httpVersion; RWIHttpAgent agent("www.roguewave.com", httpVersion); // 1 RWTIOUResult<RWSocketPortal> iouResult; iouResult = agent.get("/"); // 2 RWSocketPortal portal = iouResult.redeem(); // 3 RWCString temp, body; while(!(temp = portal.recv()).isNull()) // 4 body += temp;
//1 | Creates an RWIHttpAgent class connected to www.roguewave.com. All requests are sent as HTTP/1.0 compliant requests. |
//2 | Requests the root document from the server. It is returned as an IOU. |
//3 | Redeems the IOU for the RWSocketPortal, and stores it in an actual RWSocketPortal instance. |
//4 | Loops over the portal extracting the body of the message, and stores it in the RWCString body. |
Example 33 shows how to do the same task using RWHttpAgent.
RWHttpAgent agent; // 1 RWTIOUResult<RWHttpReply> iouReply = // 2 agent.executeGet(RWURL("http://www.roguewave.com/")); RWHttpReply reply = iouReply.redeem(); // 3 RWCString body = reply.getBody(); // 4
//1 | Creates an RWHttpAgent. Connection information is not necessary because connections are created when needed. |
//2 | Requests the root document from www.roguewave.com using an RWURL object. |
//3 | Redeems the returned IOU for an RWHttpReply object. |
//4 | Gets the body of the message from the RWHttpReply. |
© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.