Skip to content

Commit

Permalink
Replace InvalidMemoryOperationError by a proper AssertError in HTTPCl…
Browse files Browse the repository at this point in the history
…ientResponse.~this. See #273.
  • Loading branch information
s-ludwig committed Jul 30, 2013
1 parent c79ff20 commit c79919b
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions source/vibe/http/client.d
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import vibe.stream.zlib;
import vibe.utils.array;
import vibe.utils.memory;

import core.exception : AssertError;
import std.array;
import std.conv;
import std.exception;
Expand Down Expand Up @@ -376,6 +377,7 @@ deprecated("Please use HTTPClientRequest instead.") alias HttpClientRequest = HT

final class HTTPClientResponse : HTTPResponse {
private {
__gshared ms_staleResponseError = cast(immutable)new AssertError("Stale HTTP response detected. Use .dropBody() or the scoped version of requestHTTP.");
HTTPClient m_client;
LockedConnection!HTTPClient lockedConnection;
FreeListRef!LimitedInputStream m_limitedInputStream;
Expand Down Expand Up @@ -435,11 +437,7 @@ final class HTTPClientResponse : HTTPResponse {

~this()
{
assert (!m_client, "Stale HTTP response is finalized!");
if( m_client ){
logDebug("Warning: dropping unread body.");
dropBody();
}
if (m_client) throw ms_staleResponseError;
}

/**
Expand Down

0 comments on commit c79919b

Please sign in to comment.