13 * |
13 * |
14 * Description: |
14 * Description: |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #include <uri8.h> |
18 #include <Uri8.h> |
19 #include <escapeutils.h> |
19 #include <EscapeUtils.h> |
20 #include <http/rhttpheaders.h> |
20 #include <http/rhttpheaders.h> |
21 #include <http/mhttpdatasupplier.h> |
21 #include <http/mhttpdatasupplier.h> |
22 #include <thttpfields.h> |
22 #include <thttpfields.h> |
23 #include "ResourceHandle.h" |
23 #include "ResourceHandle.h" |
24 #include "ResourceHandleInternal.h" |
24 #include "ResourceHandleInternal.h" |
28 #include "StaticObjectsContainer.h" |
28 #include "StaticObjectsContainer.h" |
29 #include "ResourceLoaderDelegate.h" |
29 #include "ResourceLoaderDelegate.h" |
30 #include "HttpCacheSupply.h" |
30 #include "HttpCacheSupply.h" |
31 #include "HttpPostDataSupplier.h" |
31 #include "HttpPostDataSupplier.h" |
32 #include <httpfiltercommonstringsext.h> |
32 #include <httpfiltercommonstringsext.h> |
33 #include <BrCtlDefs.h> |
33 #include <brctldefs.h> |
34 #include "BrCtl.h" |
34 #include "BrCtl.h" |
35 #include "BrCtlSpecialLoadObserver.h" |
35 #include <brctlspecialloadobserver.h> |
36 #include "Frame.h" |
36 #include "Frame.h" |
37 #include "FrameLoader.h" |
37 #include "FrameLoader.h" |
38 #include "DocumentLoader.h" |
38 #include "DocumentLoader.h" |
39 #include "HttpUiCallbacks.h" |
39 #include "HttpUiCallbacks.h" |
40 #include "HttpRequestHeaderManager.h" |
40 #include "HttpRequestHeaderManager.h" |
81 return KErrNone; |
81 return KErrNone; |
82 } |
82 } |
83 |
83 |
84 void DefersData::Activate() |
84 void DefersData::Activate() |
85 { |
85 { |
86 SetActive(); |
86 if(!IsActive()) |
87 iStatus = KRequestPending; |
87 { |
88 TRequestStatus* status = &iStatus; |
88 SetActive(); |
89 User::RequestComplete( status, KErrNone ); |
89 iStatus = KRequestPending; |
|
90 TRequestStatus* status = &iStatus; |
|
91 User::RequestComplete( status, KErrNone ); |
|
92 } |
90 } |
93 } |
91 |
94 |
92 |
95 |
93 ReceivedFinished::ReceivedFinished(void* ctx, ReceivedFinishedCallback callback) : CActive(CActive::EPriorityStandard) |
96 ReceivedFinished::ReceivedFinished(void* ctx, ReceivedFinishedCallback callback) : CActive(CActive::EPriorityStandard) |
94 { |
97 { |
175 delete m_defersData; |
178 delete m_defersData; |
176 delete m_receivedFinished; |
179 delete m_receivedFinished; |
177 delete m_unknownContentHandler; |
180 delete m_unknownContentHandler; |
178 delete m_cacheSupply; |
181 delete m_cacheSupply; |
179 delete m_postDataSupplier; |
182 delete m_postDataSupplier; |
|
183 if(m_transaction) |
|
184 m_transaction->Close(); |
180 delete m_transaction; |
185 delete m_transaction; |
181 } |
186 } |
182 |
187 |
183 HttpConnection* HttpConnection::connectionFromTransaction(RHTTPTransaction& transaction) |
188 HttpConnection* HttpConnection::connectionFromTransaction(RHTTPTransaction& transaction) |
184 { |
189 { |
202 } |
207 } |
203 |
208 |
204 void HttpConnection::submitL() |
209 void HttpConnection::submitL() |
205 { |
210 { |
206 __ASSERT_DEBUG( !m_transaction, THttpConnUtils::PanicLoader( KErrArgument ) ); |
211 __ASSERT_DEBUG( !m_transaction, THttpConnUtils::PanicLoader( KErrArgument ) ); |
|
212 TBool retryFlag = StaticObjectsContainer::instance()->resourceLoaderDelegate()->httpSessionManager()->getRetryConnectivityFlag(); |
|
213 if( retryFlag ) |
|
214 return; |
207 |
215 |
208 HttpSessionManager* httpSessionMgr = StaticObjectsContainer::instance()->resourceLoaderDelegate()->httpSessionManager(); |
216 HttpSessionManager* httpSessionMgr = StaticObjectsContainer::instance()->resourceLoaderDelegate()->httpSessionManager(); |
209 User::LeaveIfNull(httpSessionMgr); |
217 User::LeaveIfNull(httpSessionMgr); |
210 httpSessionMgr->openHttpSessionIfNeededL(); |
218 httpSessionMgr->openHttpSessionIfNeededL(); |
211 TPtrC8 urlPtr( m_handle->request().url().des() ); |
219 TPtrC8 urlPtr( m_handle->request().url().des() ); |
646 if (!m_transaction) { |
659 if (!m_transaction) { |
647 // this object might be invalid at this point. |
660 // this object might be invalid at this point. |
648 return; |
661 return; |
649 } |
662 } |
650 int statusCode = m_transaction->Response().StatusCode(); |
663 int statusCode = m_transaction->Response().StatusCode(); |
651 if ( statusCode != 200) { |
664 if ((statusCode == 404) && (aEvent.iStatus == THTTPEvent::EFailed) && (m_accumulatedSize != 0)) { |
|
665 complete(KErrNone); |
|
666 } |
|
667 else if ( statusCode != 200) { |
652 complete(-25000 - m_transaction->Response().StatusCode()); |
668 complete(-25000 - m_transaction->Response().StatusCode()); |
653 } |
669 } |
654 else if (statusCode == 200 && aEvent.iStatus == THTTPEvent::EFailed) { |
670 else if (statusCode == 200 && aEvent.iStatus == THTTPEvent::EFailed) { |
655 // this is a weird combination, it is caused by cached supplier when a response only has the |
671 // this is a weird combination, it is caused by cached supplier when a response only has the |
656 // response header, but no response body is sent by the HTTP stack. It is a legitimate senario though. |
672 // response header, but no response body is sent by the HTTP stack. It is a legitimate senario though. |
699 TPtrC8 uriNoFrag; |
715 TPtrC8 uriNoFrag; |
700 // extract non-fragment portion into uriNoFrag |
716 // extract non-fragment portion into uriNoFrag |
701 uriParser.UriWithoutFragment( uriNoFrag ); |
717 uriParser.UriWithoutFragment( uriNoFrag ); |
702 TUriParser8 parserNoFrag; |
718 TUriParser8 parserNoFrag; |
703 parserNoFrag.Parse( uriNoFrag ); |
719 parserNoFrag.Parse( uriNoFrag ); |
704 m_transaction->Request().SetURIL( parserNoFrag ); |
|
705 // now save the fragment for later use |
720 // now save the fragment for later use |
706 const TDesC8& fragment = uriParser.Extract( EUriFragment ); |
721 const TDesC8& fragment = uriParser.Extract( EUriFragment ); |
707 delete m_frag; |
722 delete m_frag; |
708 m_frag = NULL; |
723 m_frag = NULL; |
709 m_frag = fragment.AllocL(); |
724 //Browser does not allow fragment size of greater than 2083 bytes |
|
725 TInt32 maxbyte = fragment.Length(); |
|
726 if ( maxbyte <= 2083) |
|
727 { |
|
728 m_frag = fragment.AllocL(); |
|
729 } |
|
730 m_transaction->Request().SetURIL( parserNoFrag ); |
710 } |
731 } |
711 HandleSpecialEvent(aEvent.iStatus); |
732 HandleSpecialEvent(aEvent.iStatus); |
712 break; |
733 break; |
713 } |
734 } |
714 case THTTPEvent::EGotResponseTrailerHeaders: |
735 case THTTPEvent::EGotResponseTrailerHeaders: |
809 CResourceHandleManager::self()->receivedResponse(m_handle, response, this); |
845 CResourceHandleManager::self()->receivedResponse(m_handle, response, this); |
810 CResourceHandleManager::self()->receivedData(m_handle, |
846 CResourceHandleManager::self()->receivedData(m_handle, |
811 m_MultipartContentHandler->MarkupContent(), m_maxSize, this); |
847 m_MultipartContentHandler->MarkupContent(), m_maxSize, this); |
812 } |
848 } |
813 delete m_MultipartContentHandler; |
849 delete m_MultipartContentHandler; |
|
850 m_IsMultipart = false; |
814 } |
851 } |
815 if (!error) { |
852 if (!error) { |
816 // Spawn active object for call to return immediately, to avoid blocking |
853 // Spawn active object for call to return immediately, to avoid blocking |
817 activateReceivedFinished(error); |
854 activateReceivedFinished(error); |
818 } |
855 } |
828 if (m_transaction) { |
865 if (m_transaction) { |
829 m_transaction->Cancel(); |
866 m_transaction->Cancel(); |
830 m_transaction->Close(); |
867 m_transaction->Close(); |
831 delete m_transaction; |
868 delete m_transaction; |
832 m_transaction = NULL; |
869 m_transaction = NULL; |
|
870 httpSessionManager->removeRequest(this); |
833 } |
871 } |
834 if (error) { |
872 if (error) { |
835 CResourceHandleManager::self()->receivedFinished(m_handle, error, this); |
873 CResourceHandleManager::self()->receivedFinished(m_handle, error, this); |
836 derefHandle(); |
874 derefHandle(); |
837 } |
875 } |
1029 // Execution is back from the dialog, move the transaction |
1067 // Execution is back from the dialog, move the transaction |
1030 // from the authentication listback into active list |
1068 // from the authentication listback into active list |
1031 HttpSessionManager* httpSessionMgr = StaticObjectsContainer::instance()->resourceLoaderDelegate()->httpSessionManager(); |
1069 HttpSessionManager* httpSessionMgr = StaticObjectsContainer::instance()->resourceLoaderDelegate()->httpSessionManager(); |
1032 httpSessionMgr->removeAuthRequest(this); |
1070 httpSessionMgr->removeAuthRequest(this); |
1033 httpSessionMgr->addRequest(this, m_handle); |
1071 httpSessionMgr->addRequest(this, m_handle); |
1034 |
1072 m_isDone = EFalse; |
1035 switch (aError) |
1073 switch (aError) |
1036 { |
1074 { |
1037 case KErrNone: |
1075 case KErrNone: |
1038 { |
1076 { |
1039 TRAP( ret, this->AddAuthenticationPropertiesL( aUsername, aPassword, aProxy) ); |
1077 TRAP( ret, this->AddAuthenticationPropertiesL( aUsername, aPassword, aProxy) ); |
1153 } |
1191 } |
1154 } |
1192 } |
1155 //When submitting the request iSecurePage was set based on the request url |
1193 //When submitting the request iSecurePage was set based on the request url |
1156 //Check the redirect url and see if the scheme has changed |
1194 //Check the redirect url and see if the scheme has changed |
1157 HttpSessionManager* httpSessionMgr = StaticObjectsContainer::instance()->resourceLoaderDelegate()->httpSessionManager(); |
1195 HttpSessionManager* httpSessionMgr = StaticObjectsContainer::instance()->resourceLoaderDelegate()->httpSessionManager(); |
1158 if(requestedSecScheme && !redirectedSecScheme) //redirection from a secure page to an unsecure one |
1196 if(httpSessionMgr->isInSecureConnection() && requestedSecScheme && !redirectedSecScheme) //redirection from a secure page to an unsecure one |
1159 { |
1197 { |
1160 error = httpSessionMgr->uiCallback()->aboutToLoadPage(control(m_frame), HttpUiCallbacks::EExitingSecurePage); |
1198 error = httpSessionMgr->uiCallback()->aboutToLoadPage(control(m_frame), HttpUiCallbacks::EExitingSecurePage); |
1161 } |
1199 httpSessionMgr->setInSecureConnection(EFalse); |
1162 else if(redirectedSecScheme && !requestedSecScheme) //redirection to unsecurepage when secure page was requested |
1200 } |
|
1201 else if(!httpSessionMgr->isInSecureConnection() && redirectedSecScheme && !requestedSecScheme) //redirection to unsecurepage when secure page was requested |
1163 { |
1202 { |
1164 error = httpSessionMgr->uiCallback()->aboutToLoadPage(control(m_frame), HttpUiCallbacks::EEnteringSecurePage ); |
1203 error = httpSessionMgr->uiCallback()->aboutToLoadPage(control(m_frame), HttpUiCallbacks::EEnteringSecurePage ); |
1165 } |
1204 httpSessionMgr->setInSecureConnection(ETrue); |
1166 } |
1205 } |
|
1206 } |
1167 return error; |
1207 return error; |
1168 } |
1208 } |
1169 |
1209 |
1170 // ----------------------------------------------------------------------------- |
1210 // ----------------------------------------------------------------------------- |
1171 // HttpConnection::CheckForNonHttpRedirect |
1211 // HttpConnection::CheckForNonHttpRedirect |
1178 |
1218 |
1179 __ASSERT_DEBUG( m_transaction, THttpConnUtils::PanicLoader( KErrArgument ) ); |
1219 __ASSERT_DEBUG( m_transaction, THttpConnUtils::PanicLoader( KErrArgument ) ); |
1180 |
1220 |
1181 if(uriParser.Parse( m_transaction->Request().URI().UriDes() ) == KErrNone) |
1221 if(uriParser.Parse( m_transaction->Request().URI().UriDes() ) == KErrNone) |
1182 { |
1222 { |
1183 if (uriParser.IsPresent(EUriHost) && uriParser.IsPresent(EUriScheme)) // looking only for absolue Url path and schemes other than http(s) |
1223 if (uriParser.IsPresent(EUriScheme)) // looking only for absolue Url path and schemes other than http(s) |
1184 { |
1224 { |
1185 const TDesC8& scheme = uriParser.Extract(EUriScheme); |
1225 const TDesC8& scheme = uriParser.Extract(EUriScheme); |
1186 if (scheme.FindF(_L8("http")) == KErrNotFound) // everything but http(s) |
1226 if(uriParser.IsPresent(EUriHost) || scheme.FindF(_L8("tel")) == KErrNone) |
1187 { |
1227 { |
1188 TPtrC8 ptr(uriParser.UriDes()); |
1228 if (scheme.FindF(_L8("http")) == KErrNotFound) // everything but http(s) |
1189 // these arrays are pushed into CleanupStack in case leave |
|
1190 // if no leave, they will be freed below |
|
1191 RArray<TUint>* typeArray = new (ELeave) RArray<TUint>(1); |
|
1192 CleanupStack::PushL(typeArray); |
|
1193 |
|
1194 CDesCArrayFlat* desArray = new (ELeave) CDesCArrayFlat(1); |
|
1195 CleanupStack::PushL(desArray); |
|
1196 |
|
1197 User::LeaveIfError(typeArray->Append(EParamRequestUrl)); |
|
1198 |
|
1199 HBufC16* urlbuf = HBufC16::NewLC( ptr.Length() + 1); // +1 for zero terminate |
|
1200 urlbuf->Des().Copy( ptr ); |
|
1201 TPtr16 bufDes16 = urlbuf->Des(); |
|
1202 bufDes16.ZeroTerminate(); |
|
1203 |
|
1204 desArray->AppendL(bufDes16); |
|
1205 CleanupStack::Pop(); |
|
1206 |
|
1207 MBrCtlSpecialLoadObserver* loadObserver = control(m_frame)->brCtlSpecialLoadObserver(); |
|
1208 |
|
1209 if (loadObserver) |
|
1210 { |
1229 { |
1211 TRAP_IGNORE(loadObserver->HandleRequestL(typeArray, desArray)); |
1230 TPtrC8 ptr(uriParser.UriDes()); |
1212 } |
1231 // these arrays are pushed into CleanupStack in case leave |
1213 |
1232 // if no leave, they will be freed below |
1214 // No leave, so pop here and clean up |
1233 RArray<TUint>* typeArray = new (ELeave) RArray<TUint>(1); |
1215 CleanupStack::Pop(desArray); |
1234 CleanupStack::PushL(typeArray); |
1216 CleanupStack::Pop(typeArray); |
1235 |
1217 |
1236 CDesCArrayFlat* desArray = new (ELeave) CDesCArrayFlat(1); |
1218 // cleanup arrays |
1237 CleanupStack::PushL(desArray); |
1219 if (typeArray) |
1238 |
1220 { |
1239 User::LeaveIfError(typeArray->Append(EParamRequestUrl)); |
1221 // Closes the array and frees all memory allocated to the array |
1240 |
1222 typeArray->Close(); |
1241 HBufC16* urlbuf = HBufC16::NewLC( ptr.Length() + 1); // +1 for zero terminate |
1223 delete typeArray; |
1242 urlbuf->Des().Copy( ptr ); |
1224 } |
1243 TPtr16 bufDes16 = urlbuf->Des(); |
1225 |
1244 bufDes16.ZeroTerminate(); |
1226 if (desArray) |
1245 |
1227 { |
1246 desArray->AppendL(bufDes16); |
1228 // Deletes all descriptors from the array and frees the memory allocated to the array buffer |
1247 CleanupStack::Pop(); |
1229 desArray->Reset(); |
1248 |
1230 delete desArray; |
1249 MBrCtlSpecialLoadObserver* loadObserver = control(m_frame)->brCtlSpecialLoadObserver(); |
1231 } |
1250 |
1232 |
1251 if (loadObserver) |
1233 return KErrCancel; |
1252 { |
|
1253 TRAP_IGNORE(loadObserver->HandleRequestL(typeArray, desArray)); |
|
1254 } |
|
1255 |
|
1256 // No leave, so pop here and clean up |
|
1257 CleanupStack::Pop(desArray); |
|
1258 CleanupStack::Pop(typeArray); |
|
1259 |
|
1260 // cleanup arrays |
|
1261 if (typeArray) |
|
1262 { |
|
1263 // Closes the array and frees all memory allocated to the array |
|
1264 typeArray->Close(); |
|
1265 delete typeArray; |
|
1266 } |
|
1267 |
|
1268 if (desArray) |
|
1269 { |
|
1270 // Deletes all descriptors from the array and frees the memory allocated to the array buffer |
|
1271 desArray->Reset(); |
|
1272 delete desArray; |
|
1273 } |
|
1274 |
|
1275 return KErrCancel; |
|
1276 } |
1234 } |
1277 } |
1235 } |
1278 } |
1236 } |
1279 } |
1237 return KErrNone; |
1280 return KErrNone; |
1238 } |
1281 } |
1244 RHTTPTransaction* trans = m_transaction; |
1287 RHTTPTransaction* trans = m_transaction; |
1245 RHTTPSession& session = StaticObjectsContainer::instance()->resourceLoaderDelegate()->httpSessionManager()->httpSession(); |
1288 RHTTPSession& session = StaticObjectsContainer::instance()->resourceLoaderDelegate()->httpSessionManager()->httpSession(); |
1246 // remove own address from transaction properties |
1289 // remove own address from transaction properties |
1247 m_transaction->PropertySet().RemoveProperty(session.StringPool().StringF(HttpFilterCommonStringsExt::ESelfPtr, |
1290 m_transaction->PropertySet().RemoveProperty(session.StringPool().StringF(HttpFilterCommonStringsExt::ESelfPtr, |
1248 HttpFilterCommonStringsExt::GetTable())); |
1291 HttpFilterCommonStringsExt::GetTable())); |
|
1292 if(m_cacheSupply->IsSupplying()) |
|
1293 { |
|
1294 //Download is started from cache. |
|
1295 m_cacheSupply->SetDownloadTransaction(m_transaction); |
|
1296 } |
1249 m_transaction = NULL; |
1297 m_transaction = NULL; |
|
1298 m_isDone = true; |
1250 return trans; |
1299 return trans; |
1251 } |
1300 } |
1252 |
1301 |
1253 // ----------------------------------------------------------------------------- |
1302 // ----------------------------------------------------------------------------- |
1254 // HttpConnection::addIMEINotifyPropertiesL |
1303 // HttpConnection::addIMEINotifyPropertiesL |