Bug 1133763 - Part 1: Remember the security info associated with HTTP fetches and record it inside InternalResponse; r=nsm

This commit is contained in:
Ehsan Akhgari 2015-03-04 16:05:21 -05:00
Родитель eed5a8dba4
Коммит 08a57b8a9e
4 изменённых файлов: 40 добавлений и 0 удалений

Просмотреть файл

@ -665,6 +665,12 @@ FetchDriver::OnStartRequest(nsIRequest* aRequest,
mResponse = BeginAndGetFilteredResponse(response);
nsCOMPtr<nsISupports> securityInfo;
rv = channel->GetSecurityInfo(getter_AddRefs(securityInfo));
if (securityInfo) {
mResponse->SetSecurityInfo(securityInfo);
}
// We open a pipe so that we can immediately set the pipe's read end as the
// response's body. Setting the segment size to UINT32_MAX means that the
// pipe has infinite space. The nsIChannel will continue to buffer data in

Просмотреть файл

@ -9,6 +9,7 @@
#include "mozilla/dom/InternalHeaders.h"
#include "nsStreamUtils.h"
#include "nsSerializationHelper.h"
namespace mozilla {
namespace dom {
@ -84,5 +85,24 @@ InternalResponse::CORSResponse(InternalResponse* aInner)
return cors.forget();
}
void
InternalResponse::SetSecurityInfo(nsISupports* aSecurityInfo)
{
MOZ_ASSERT(mSecurityInfo.IsEmpty(), "security info should only be set once");
nsCOMPtr<nsISerializable> serializable = do_QueryInterface(aSecurityInfo);
if (!serializable) {
NS_WARNING("A non-serializable object was passed to InternalResponse::SetSecurityInfo");
return;
}
NS_SerializeToString(serializable, mSecurityInfo);
}
void
InternalResponse::SetSecurityInfo(const nsCString& aSecurityInfo)
{
MOZ_ASSERT(mSecurityInfo.IsEmpty(), "security info should only be set once");
mSecurityInfo = aSecurityInfo;
}
} // namespace dom
} // namespace mozilla

Просмотреть файл

@ -126,6 +126,18 @@ public:
mBody = aBody;
}
const nsCString&
GetSecurityInfo() const
{
return mSecurityInfo;
}
void
SetSecurityInfo(nsISupports* aSecurityInfo);
void
SetSecurityInfo(const nsCString& aSecurityInfo);
private:
~InternalResponse()
{ }
@ -143,6 +155,7 @@ private:
nsRefPtr<InternalHeaders> mHeaders;
nsCOMPtr<nsIInputStream> mBody;
nsCString mContentType;
nsCString mSecurityInfo;
};
} // namespace dom

Просмотреть файл

@ -146,6 +146,7 @@ EXPORTS += [
'nsMIMEInputStream.h',
'nsNetUtil.h',
'nsReadLine.h',
'nsSerializationHelper.h',
'nsSimpleNestedURI.h',
'nsSimpleURI.h',
'nsStreamListenerWrapper.h',