зеркало из https://github.com/mozilla/gecko-dev.git
fixes bug 227976 "nsHttpCompressConv can fail to read any data in OnDataAvailable and return success" r=biesi (patch based on suggestion by bzbarsky)
This commit is contained in:
Родитель
914def148f
Коммит
d3d852ccbd
|
@ -1,4 +1,5 @@
|
||||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||||
|
/* vim:set ts=4 sw=4 sts=4 cindent et: */
|
||||||
/* ***** BEGIN LICENSE BLOCK *****
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
*
|
*
|
||||||
|
@ -46,6 +47,18 @@
|
||||||
#include "nsIByteArrayInputStream.h"
|
#include "nsIByteArrayInputStream.h"
|
||||||
#include "nsIStringStream.h"
|
#include "nsIStringStream.h"
|
||||||
|
|
||||||
|
static NS_METHOD
|
||||||
|
DiscardSegments(nsIInputStream *input,
|
||||||
|
void *closure,
|
||||||
|
const char *buf,
|
||||||
|
PRUint32 offset,
|
||||||
|
PRUint32 count,
|
||||||
|
PRUint32 *countRead)
|
||||||
|
{
|
||||||
|
*countRead = count;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
// nsISupports implementation
|
// nsISupports implementation
|
||||||
NS_IMPL_THREADSAFE_ISUPPORTS2(nsHTTPCompressConv, nsIStreamConverter, nsIStreamListener)
|
NS_IMPL_THREADSAFE_ISUPPORTS2(nsHTTPCompressConv, nsIStreamConverter, nsIStreamListener)
|
||||||
|
|
||||||
|
@ -132,10 +145,22 @@ nsHTTPCompressConv::OnDataAvailable(nsIRequest* request,
|
||||||
PRUint32 aCount)
|
PRUint32 aCount)
|
||||||
{
|
{
|
||||||
nsresult rv = NS_ERROR_FAILURE;
|
nsresult rv = NS_ERROR_FAILURE;
|
||||||
PRUint32 streamLen = aCount;
|
PRUint32 streamLen = aCount;
|
||||||
|
|
||||||
if (streamLen == 0 || mStreamEnded)
|
if (streamLen == 0)
|
||||||
return NS_OK; // XXX an error code would make more sense, no?
|
{
|
||||||
|
NS_ERROR("count of zero passed to OnDataAvailable");
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mStreamEnded)
|
||||||
|
{
|
||||||
|
// Hmm... this may just indicate that the data stream is done and that
|
||||||
|
// what's left is either metadata or padding of some sort.... throwing
|
||||||
|
// it out is probably the safe thing to do.
|
||||||
|
PRUint32 n;
|
||||||
|
return iStr->ReadSegments(DiscardSegments, nsnull, streamLen, &n);
|
||||||
|
}
|
||||||
|
|
||||||
switch (mMode)
|
switch (mMode)
|
||||||
{
|
{
|
||||||
|
|
Загрузка…
Ссылка в новой задаче