Return-Path: X-Original-To: apmail-hc-httpclient-users-archive@www.apache.org Delivered-To: apmail-hc-httpclient-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8415F177DF for ; Tue, 28 Jul 2015 12:53:22 +0000 (UTC) Received: (qmail 13680 invoked by uid 500); 28 Jul 2015 12:46:33 -0000 Delivered-To: apmail-hc-httpclient-users-archive@hc.apache.org Received: (qmail 13637 invoked by uid 500); 28 Jul 2015 12:46:33 -0000 Mailing-List: contact httpclient-users-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpClient User Discussion" Delivered-To: mailing list httpclient-users@hc.apache.org Received: (qmail 13625 invoked by uid 99); 28 Jul 2015 12:46:33 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Jul 2015 12:46:33 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id B7B7119228A for ; Tue, 28 Jul 2015 12:46:32 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.041 X-Spam-Level: ** X-Spam-Status: No, score=2.041 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, HTML_MESSAGE=3, RCVD_IN_MSPIKE_H2=-1.108, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id u4N-R-jtOnSd for ; Tue, 28 Jul 2015 12:46:32 +0000 (UTC) Received: from mail-ig0-f175.google.com (mail-ig0-f175.google.com [209.85.213.175]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with ESMTPS id AD1B642ADC for ; Tue, 28 Jul 2015 12:46:31 +0000 (UTC) Received: by igbij6 with SMTP id ij6so113965576igb.1 for ; Tue, 28 Jul 2015 05:45:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=RM0CnofR0IN63TkD3FbHIe1eDIYScRD/McHZo+JU5fY=; b=M/WB3Z1eT8ZoW0Rz+EQgu2sLdAMBaFHQI+kDfNZ/HiSShB8p73c42ys7ny9S8Tjpmf PxcT8XprgD99QaEsHV3bAP55ZtQXWvpO7dl6Y4MW7ImzGezinAII7vrIKf5gQsAn9xoR 0FZeUTleaGHQv8RLCNxHG/yHrOBfmANajRIpOTBPrBddkSdiIDY86JTvbo8yeHgpm/rt 0JAElo/bDzrJ9JO73rAnRholcvvLPziI7Mj+fn+Dh9uuHh2cpw5vwA1rdMgusASgYSOM qx+ksdKsNhcs6kwsNhRZZmYqu89pvcm2QNRW1gt21GolW5ATeGCc/CVq/iHx6ncLNhPH X1pA== MIME-Version: 1.0 X-Received: by 10.50.44.18 with SMTP id a18mr6561922igm.52.1438087546360; Tue, 28 Jul 2015 05:45:46 -0700 (PDT) Received: by 10.79.76.209 with HTTP; Tue, 28 Jul 2015 05:45:46 -0700 (PDT) Date: Tue, 28 Jul 2015 20:45:46 +0800 Message-ID: Subject: How to close the underlying connection within callback? From: Cap zhou To: httpclient-users@hc.apache.org Content-Type: multipart/alternative; boundary=e89a8f8393f95b5bed051beed9ff --e89a8f8393f95b5bed051beed9ff Content-Type: text/plain; charset=UTF-8 Hi: I want to close the underlying connection if the status code of response is not 2XX, or I don't want the connection to be reused if any request on it has ever failed. how? I am using httpasyncclient 4.0.2. why I want to do this? Because in some situations my server may return error right after it finished receiving the http headers while the body is not completed. And the client may stop sending body if it receive the response. And if the connection is reused by another request, the data of http header of the new request may consider to be the rest body data of the last request. Then the second request will fail with an unexpected exception. My solution to this problem is: don't reuse the connection if any request has failed it. --e89a8f8393f95b5bed051beed9ff--