When a GET request is initiated to the server, a page Jump information is sometimes returned, which is reflected in the specific value of httphearder: 302 or 301, there is no essential difference between the two for users.
The solution is as follows:
1. It can be processed directly in mhfrunl:
Void chttpengine: mhfrunl (rhttptransaction atransaction, const thttpevent & aevent) {Switch (aevent. istatus) {Case thttpevent: eredirectedtemporarily: Case thttpevent: eredirectedpermanently: {Iuri = atransaction. request (). uri (). urides (). alloc ();}}
Eredirectedtemporarily and eredirectedpermanently correspond to 301 and 302 respectively. The system automatically resends a GET request to the URL after the jump.
However, when I tested using Wi-Fi and cmwap access points, I found that the data returned by the GET request was delayed. So I can only manually resend it myself:
Void chttpengine: mhfrunl (rhttptransaction atransaction, const thttpevent & aevent) {Switch (aevent. istatus) {Case thttpevent: eredirectedtemporarily: Case thttpevent: eredirectedpermanently: {Iuri = atransaction. request (). uri (). urides (). alloc (); atransaction. close (); // close the current session sendgetl (* Iuri); // send a new GET request }}
2. Another processing method is to remove the filter for redirect processing in the HTTP engine:
Rstringpool pool = isession. stringpool (); isession. filtercollection (). removefilter (pool. stringf (http: eredirect, rhttpsession: gettable ()));
Then, make a judgment in mhfrunl:
Void chttpengine: mhfrunl (rhttptransaction atransaction, const thttpevent & aevent) {Switch (aevent. istatus) {Case thttpevent: egotresponseheaders: {rhttpresponse resp = atransaction. response (); ireeclipsecode = resp. statuscode (); If (iresponsecode = 302 | iresponsecode = 301) {rstringf slocation = isession. stringpool (). stringf (http: elocation, rhttpsession: gettable (); thttphdrval headerlocation; resp. getheadercollection (). getfield (slocation, 0, headerlocation); ilocationurl = headerlocation. STRF (). DESC (). alloc (); // gets the redirected URL slocation. close (); atransaction. close (); sendgetl (* ilocationurl );}}}}
In this way, the Wi-Fi and cmwap access points have no response after getting again during the test.
This article is original for students. If you need to reprint it, please indicate the source.