16 */ |
16 */ |
17 |
17 |
18 |
18 |
19 // INCLUDE FILES |
19 // INCLUDE FILES |
20 #include <http.h> |
20 #include <http.h> |
21 #include <BrowserUiSDKCRKeys.h> |
21 #include <browseruisdkcrkeys.h> |
22 #include "HttpRequestHeaderManager.h" |
22 #include "HttpRequestHeaderManager.h" |
23 #include "httpfiltercommonstringsext.h" |
23 #include "httpfiltercommonstringsext.h" |
24 #include "ResourceRequest.h" |
24 #include "ResourceRequest.h" |
25 #include "StaticObjectsContainer.h" |
25 #include "StaticObjectsContainer.h" |
26 #include "ResourceLoaderDelegate.h" |
26 #include "ResourceLoaderDelegate.h" |
27 #include <syslangutil.h> |
27 #include <SysLangUtil.h> |
28 #include "WebCharsetData.h" |
28 #include "WebCharsetData.h" |
29 #include <tinternetdate.h> |
29 #include <tinternetdate.h> |
30 |
30 |
31 // EXTERNAL FUNCTION PROTOTYPES |
31 // EXTERNAL FUNCTION PROTOTYPES |
32 |
32 |
39 _LIT ( KQualPtSeven, ";q=0.7" ); |
39 _LIT ( KQualPtSeven, ";q=0.7" ); |
40 _LIT8( KNoCache, "no-cache" ); |
40 _LIT8( KNoCache, "no-cache" ); |
41 _LIT8( KOnlyIfCached, "only-if-cached" ); |
41 _LIT8( KOnlyIfCached, "only-if-cached" ); |
42 _LIT8( KQHalfValue, ";q=0.5" ); |
42 _LIT8( KQHalfValue, ";q=0.5" ); |
43 _LIT8( KQWholeValue, ";q=1.0" ); |
43 _LIT8( KQWholeValue, ";q=1.0" ); |
|
44 _LIT8( KAccept, "Accept" ); |
|
45 _LIT ( AcceptHeader, "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,image/png,*/*;q=0.5" ); |
44 const TUint KDefBufSize = 512; |
46 const TUint KDefBufSize = 512; |
45 const TInt KLangStrLen = 10; |
47 const TInt KLangStrLen = 10; |
46 const TUint KCharsetUidDef = KCharacterSetIdentifierIso88591; |
48 const TUint KCharsetUidDef = KCharacterSetIdentifierIso88591; |
47 // LOCAL FUNCTIONS |
49 // LOCAL FUNCTIONS |
48 |
50 |
541 TPtrC strValuePtr(headerValue.des()); |
543 TPtrC strValuePtr(headerValue.des()); |
542 HBufC8* strValueBuf = HBufC8::NewLC(strValuePtr.Length()); |
544 HBufC8* strValueBuf = HBufC8::NewLC(strValuePtr.Length()); |
543 strValueBuf->Des().Copy(strValuePtr); |
545 strValueBuf->Des().Copy(strValuePtr); |
544 RStringF strValue = m_StringPool.OpenFStringL( strValueBuf->Des() ); |
546 RStringF strValue = m_StringPool.OpenFStringL( strValueBuf->Des() ); |
545 CleanupClosePushL(strValue ); |
547 CleanupClosePushL(strValue ); |
546 |
548 |
|
549 HBufC8* headerBuf = NULL; |
|
550 |
|
551 // Check for Accept Header |
|
552 if ((strNameBuf->Des().Compare(KAccept)) == 0) |
|
553 { |
|
554 THTTPHdrVal headerVal; |
|
555 // Store the Accept Header value from aHeaders in headerVal |
|
556 aHeaders.GetField(strName, 0, headerVal); |
|
557 headerBuf = HBufC8::NewLC( headerVal.StrF().DesC().Length() ); |
|
558 // Copy accept header value from headerVal |
|
559 headerBuf->Des().Copy(headerVal.StrF().DesC()); |
|
560 TPtrC httpAccept(AcceptHeader); |
|
561 TInt httpAcceptLen(httpAccept.Length()); |
|
562 if (httpAcceptLen) |
|
563 { |
|
564 // Find the Hardcoded accept header value in the header value received from aRequest |
|
565 TInt httpAcceptPos = strValuePtr.Find(httpAccept); |
|
566 TBool deleted(EFalse); |
|
567 if(httpAcceptPos != KErrNotFound) |
|
568 { |
|
569 // Delete the Accept header from the header Value of aRequest to avoid duplication |
|
570 strValueBuf->Des().Delete( httpAcceptPos, httpAcceptLen); |
|
571 deleted =ETrue; |
|
572 } |
|
573 //Incase the aRequest header value is different from the hardcoded accept header value |
|
574 //Compare the aRequest accept header value with accept header value of headerVal |
|
575 // |
|
576 if((deleted && strValueBuf->Length()) || (strValueBuf->Length() && strValueBuf->Compare(headerVal.StrF().DesC()) != 0)) |
|
577 { |
|
578 CleanupStack::Pop(headerBuf); |
|
579 //Reallocate the buffer size based on strValueBuf value |
|
580 //and append content of strValueBuf to headerBuf |
|
581 headerBuf = headerBuf->ReAllocL( headerVal.StrF().DesC().Length() + strValueBuf->Length() + 1); |
|
582 CleanupStack::PushL(headerBuf); |
|
583 headerBuf->Des().Append(KCommaSeperator); |
|
584 headerBuf->Des().Append(strValueBuf->Des()); |
|
585 |
|
586 } |
|
587 // Store the full accept header value to strValue |
|
588 strValue = m_StringPool.OpenFStringL( headerBuf->Des() ); |
|
589 } |
|
590 } |
|
591 |
|
592 // Remove the Accept header value from aHeaders to avoid duplication |
547 aHeaders.RemoveField(strName); |
593 aHeaders.RemoveField(strName); |
548 |
594 |
549 if (strName == m_StringPool.StringF(HTTP::EIfModifiedSince, RHTTPSession::GetTable()) || |
595 if (strName == m_StringPool.StringF(HTTP::EIfModifiedSince, RHTTPSession::GetTable()) || |
550 strName == m_StringPool.StringF(HTTP::EIfUnmodifiedSince, RHTTPSession::GetTable())) |
596 strName == m_StringPool.StringF(HTTP::EIfUnmodifiedSince, RHTTPSession::GetTable())) |
551 { |
597 { |
555 TDateTime modifyTime(date.DateTime()); |
601 TDateTime modifyTime(date.DateTime()); |
556 aHeaders.SetFieldL(strName, modifyTime); |
602 aHeaders.SetFieldL(strName, modifyTime); |
557 } |
603 } |
558 else |
604 else |
559 { |
605 { |
560 aHeaders.SetFieldL(strName, strValue); |
606 aHeaders.SetFieldL(strName, strValue); |
561 } |
607 } |
562 CleanupStack::PopAndDestroy(4); |
608 if ( headerBuf ) |
|
609 { |
|
610 CleanupStack::PopAndDestroy(headerBuf); |
|
611 } |
|
612 |
|
613 CleanupStack::PopAndDestroy(&strValue); |
|
614 CleanupStack::PopAndDestroy(strValueBuf); |
|
615 CleanupStack::PopAndDestroy(&strName); |
|
616 CleanupStack::PopAndDestroy(strNameBuf); |
563 } |
617 } |
564 } |
618 } |
565 // End of File |
619 // End of File |