Permalink
Browse files

Improve error message shown when file upload is incomplete.

  • Loading branch information...
1 parent 41160df commit 62aa07adcf556f7ebc91c9226e9c59324c722ee6 @FooBarWidget FooBarWidget committed Aug 26, 2009
Showing with 16 additions and 2 deletions.
  1. +16 −2 ext/apache2/Hooks.cpp
View
@@ -1105,7 +1105,14 @@ class Hooks {
}
if (contentLength != NULL && ftell(tempFile->handle) != atol(contentLength)) {
- throw IOException("The HTTP client sent incomplete upload data.");
+ string message = "It looks like the browser did not finish the file upload: "
+ "it said it will upload ";
+ message.append(contentLength);
+ message.append(" bytes, but it closed the connection after sending ");
+ message.append(toString(ftell(tempFile->handle)));
+ message.append(" bytes. The user probably clicked Stop in the browser "
+ "or his Internet connection stalled.");
+ throw IOException(message);
}
return tempFile;
}
@@ -1139,7 +1146,14 @@ class Hooks {
}
if (contentLength != NULL && buffer.size() != l_contentLength) {
- throw IOException("The HTTP client sent incomplete upload data.");
+ string message = "It looks like the browser did not finish the file upload: "
+ "it said it will upload ";
+ message.append(contentLength);
+ message.append(" bytes, but it closed the connection after sending ");
+ message.append(toString(buffer.size()));
+ message.append(" bytes. The user probably clicked Stop in the browser "
+ "or his Internet connection stalled.");
+ throw IOException(message);
}
}

0 comments on commit 62aa07a

Please sign in to comment.