[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[myserver-commit] [SCM] GNU MyServer branch, master, updated. 5d93aeb906
From: |
Giuseppe Scrivano |
Subject: |
[myserver-commit] [SCM] GNU MyServer branch, master, updated. 5d93aeb906b5f2e25ee8dd030d665b89dd4f5cb9 |
Date: |
Sat, 08 Aug 2009 10:14:27 +0000 |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU MyServer".
The branch, master has been updated
via 5d93aeb906b5f2e25ee8dd030d665b89dd4f5cb9 (commit)
via bdbfa76cf7ff6a80f781b14825d03ecc37abe67b (commit)
from ef155de41266092eff980e8ce0593f996a0fc099 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 5d93aeb906b5f2e25ee8dd030d665b89dd4f5cb9
Author: Giuseppe Scrivano <address@hidden>
Date: Sat Aug 8 12:10:12 2009 +0200
The HTTP Content-Range header is inclusive for the last specified byte.
Fix a bug specifying the payload 1-byte bigger than it really is.
diff --git a/myserver/src/http_handler/http_file/http_file.cpp
b/myserver/src/http_handler/http_file/http_file.cpp
index f1839e4..cfde37b 100644
--- a/myserver/src/http_handler/http_file/http_file.cpp
+++ b/myserver/src/http_handler/http_file/http_file.cpp
@@ -285,9 +285,9 @@ int HttpFile::send (HttpThreadContext* td,
ret = file->seek (firstByte);
if (ret)
{
- file->close();
+ file->close ();
delete file;
- return td->http->raiseHTTPError(500);
+ return td->http->raiseHTTPError (500);
}
/*
@@ -315,8 +315,8 @@ int HttpFile::send (HttpThreadContext* td,
*/
if (useGzip)
{
- HttpRequestHeader::Entry* e = td->request.other.get("Accept-Encoding");
- if(e)
+ HttpRequestHeader::Entry* e = td->request.other.get
("Accept-Encoding");
+ if (e)
useGzip &= (e->value->find("gzip") != string::npos);
else
useGzip = false;
@@ -337,7 +337,7 @@ int HttpFile::send (HttpThreadContext* td,
ostringstream buffer;
td->response.httpStatus = 206;
buffer << "bytes "<< (u_long)firstByte << "-"
- << (u_long)lastByte << "/" << (u_long)filesize ;
+ << (u_long) (lastByte - 1) << "/" << (u_long)filesize;
e = td->response.other.get ("Content-Range");
if (e)
commit bdbfa76cf7ff6a80f781b14825d03ecc37abe67b
Author: Giuseppe Scrivano <address@hidden>
Date: Sat Aug 8 12:02:30 2009 +0200
Rollback to read/write when sendfile fails.
diff --git a/myserver/src/base/file/file.cpp b/myserver/src/base/file/file.cpp
index efd0989..ac4f2f7 100644
--- a/myserver/src/base/file/file.cpp
+++ b/myserver/src/base/file/file.cpp
@@ -437,28 +437,44 @@ int File::read (char* buffer, u_long buffersize, u_long*
nbr)
}
/*!
- *Copy the file directly to the socket.
- *\param dest Destination socket.
- *\param firstByte File offset.
- *\param buf Temporary buffer that can be used by this function.
- *\param nbw Number of bytes sent.
+ * Copy the file directly to the socket.
+ * Return 0 on success.
+ *
+ * \param dest Destination socket.
+ * \param firstByte File offset.
+ * \param buf Temporary buffer that can be used by this function.
+ * \param nbw Number of bytes sent.
*/
int File::fastCopyToSocket (Socket *dest, u_long firstByte, MemBuf *buf,
u_long *nbw)
{
+ *nbw = 0;
#ifdef SENDFILE
off_t offset = firstByte;
- int ret = sendfile (dest->getHandle(),
- getHandle(), &offset, getFileSize () - firstByte);
+ size_t fileSize = getFileSize ();
+ while (1)
+ {
+ int ret = sendfile (dest->getHandle (), getHandle (), &offset,
+ fileSize - offset);
- if (ret < 0)
- return ret;
+ if (ret < 0)
+ {
+ /* Rollback to read/write on EINVAL or ENOSYS. */
+ if (errno == EINVAL || errno == ENOSYS)
+ break;
- *nbw = ret;
- return 0;
+ return -1;
+ }
+
+ *nbw += ret;
+
+ if (fileSize == offset)
+ return 0;
+ }
+
+ firstByte = offset;
#else
char *buffer = buf->getBuffer ();
u_long size = buf->getRealLength ();
- *nbw = 0;
if (seek (firstByte))
return 0;
@@ -479,7 +495,7 @@ int File::fastCopyToSocket (Socket *dest, u_long firstByte,
MemBuf *buf, u_long
*nbw += tmpNbw;
}
-
+
return 0;
#endif
}
-----------------------------------------------------------------------
Summary of changes:
myserver/src/base/file/file.cpp | 42 ++++++++++++++------
myserver/src/http_handler/http_file/http_file.cpp | 10 ++--
2 files changed, 34 insertions(+), 18 deletions(-)
hooks/post-receive
--
GNU MyServer
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [myserver-commit] [SCM] GNU MyServer branch, master, updated. 5d93aeb906b5f2e25ee8dd030d665b89dd4f5cb9,
Giuseppe Scrivano <=