mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1198669 - Add nsIMultiPartChannel.originalResponseHeader support. r=valentin
This commit is contained in:
parent
90bba9204f
commit
60df40e1eb
@ -12,7 +12,7 @@ interface nsIChannel;
|
||||
* associated with a MultiPartChannel.
|
||||
*/
|
||||
|
||||
[scriptable, uuid(3c329c90-2ee0-11e5-a2cb-0800200c9a66)]
|
||||
[scriptable, uuid(4fefb490-5567-11e5-a837-0800200c9a66)]
|
||||
interface nsIMultiPartChannel : nsISupports
|
||||
{
|
||||
/**
|
||||
@ -38,4 +38,9 @@ interface nsIMultiPartChannel : nsISupports
|
||||
* content-type=application/package.
|
||||
*/
|
||||
readonly attribute ACString preamble;
|
||||
|
||||
/**
|
||||
* The original http response header in each part.
|
||||
*/
|
||||
readonly attribute ACString originalResponseHeader;
|
||||
};
|
||||
|
@ -472,6 +472,19 @@ nsPartChannel::SetPreamble(const nsACString& aPreamble)
|
||||
mPreamble = aPreamble;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPartChannel::GetOriginalResponseHeader(nsACString & aOriginalResponseHeader)
|
||||
{
|
||||
aOriginalResponseHeader = mOriginalResponseHeader;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsPartChannel::SetOriginalResponseHeader(const nsACString& aOriginalResponseHeader)
|
||||
{
|
||||
mOriginalResponseHeader = aOriginalResponseHeader;
|
||||
}
|
||||
|
||||
// nsISupports implementation
|
||||
NS_IMPL_ISUPPORTS(nsMultiMixedConv,
|
||||
nsIStreamConverter,
|
||||
@ -696,9 +709,15 @@ nsMultiMixedConv::OnDataAvailable(nsIRequest *request, nsISupports *context,
|
||||
// for this "part" given the previous buffer given to
|
||||
// us in the previous OnDataAvailable callback.
|
||||
bool done = false;
|
||||
const char* originalCursor = cursor;
|
||||
rv = ParseHeaders(channel, cursor, bufLen, &done);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Append the content to the original header.
|
||||
if (cursor > originalCursor) {
|
||||
mOriginalResponseHeader.Append(originalCursor, cursor - originalCursor);
|
||||
}
|
||||
|
||||
if (done) {
|
||||
mProcessingHeaders = false;
|
||||
rv = SendStart(channel);
|
||||
@ -736,9 +755,16 @@ nsMultiMixedConv::OnDataAvailable(nsIRequest *request, nsISupports *context,
|
||||
// parse headers
|
||||
mNewPart = false;
|
||||
cursor = token;
|
||||
bool done = false;
|
||||
bool done = false;
|
||||
const char* originalCursor = cursor;
|
||||
rv = ParseHeaders(channel, cursor, bufLen, &done);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Append the content to the original header.
|
||||
if (cursor > originalCursor) {
|
||||
mOriginalResponseHeader.Append(originalCursor, cursor - originalCursor);
|
||||
}
|
||||
|
||||
if (done) {
|
||||
rv = SendStart(channel);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
@ -1035,6 +1061,10 @@ nsMultiMixedConv::SendStart(nsIChannel *aChannel) {
|
||||
// Pass preamble to the channel.
|
||||
mPartChannel->SetPreamble(mPreamble);
|
||||
|
||||
// Pass original http header.
|
||||
mPartChannel->SetOriginalResponseHeader(mOriginalResponseHeader);
|
||||
mOriginalResponseHeader = EmptyCString();
|
||||
|
||||
// We pass the headers to the nsPartChannel
|
||||
mPartChannel->SetResponseHead(mResponseHead.forget());
|
||||
|
||||
|
@ -44,6 +44,7 @@ public:
|
||||
void InitializeByteRange(int64_t aStart, int64_t aEnd);
|
||||
void SetIsLastPart() { mIsLastPart = true; }
|
||||
void SetPreamble(const nsACString& aPreamble);
|
||||
void SetOriginalResponseHeader(const nsACString& aOriginalResponseHeader);
|
||||
nsresult SendOnStartRequest(nsISupports* aContext);
|
||||
nsresult SendOnDataAvailable(nsISupports* aContext, nsIInputStream* aStream,
|
||||
uint64_t aOffset, uint32_t aLen);
|
||||
@ -89,6 +90,9 @@ protected:
|
||||
bool mIsLastPart;
|
||||
|
||||
nsCString mPreamble;
|
||||
|
||||
// The original http response header.
|
||||
nsCString mOriginalResponseHeader;
|
||||
};
|
||||
|
||||
// The nsMultiMixedConv stream converter converts a stream of type "multipart/x-mixed-replace"
|
||||
@ -196,6 +200,9 @@ protected:
|
||||
// first boundary. It's only supported by 'application/package' content type
|
||||
// and requires the boundary is defined in the HTTP header.
|
||||
nsCString mPreamble;
|
||||
|
||||
// The original http response header of each subresource.
|
||||
nsCString mOriginalResponseHeader;
|
||||
};
|
||||
|
||||
#endif /* __nsmultimixedconv__h__ */
|
||||
|
@ -149,6 +149,13 @@ multipartListener.prototype.onStartRequest = function(request, context) {
|
||||
if (headerProvider) {
|
||||
headerProvider.visitResponseHeaders(this.headerListener);
|
||||
}
|
||||
|
||||
// Verify the original header if the request is a multipart channel.
|
||||
let partChannel = request.QueryInterface(Ci.nsIMultiPartChannel);
|
||||
if (partChannel) {
|
||||
let originalHeader = this.test.content[this.testNum].headers.join("\r\n") + "\r\n\r\n";
|
||||
equal(originalHeader, partChannel.originalResponseHeader, "Oringinal header check.");
|
||||
}
|
||||
}
|
||||
|
||||
multipartListener.prototype.onDataAvailable = function(request, context, stream, offset, count) {
|
||||
|
@ -499,5 +499,11 @@ ExternalHelperAppParent::GetPreamble(nsACString & aPreamble)
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ExternalHelperAppParent::GetOriginalResponseHeader(nsACString & aOriginalResponseHeader)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
Loading…
Reference in New Issue
Block a user