Processing of 302 and 301 events in the HTTP engine of Symbian

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.