Return-Path: Delivered-To: apmail-hc-dev-archive@www.apache.org Received: (qmail 47420 invoked from network); 22 Sep 2009 13:05:10 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 22 Sep 2009 13:05:10 -0000 Received: (qmail 25107 invoked by uid 500); 22 Sep 2009 13:05:10 -0000 Delivered-To: apmail-hc-dev-archive@hc.apache.org Received: (qmail 25052 invoked by uid 500); 22 Sep 2009 13:05:10 -0000 Mailing-List: contact dev-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list dev@hc.apache.org Received: (qmail 25042 invoked by uid 99); 22 Sep 2009 13:05:10 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 Sep 2009 13:05:10 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of sebbaz@gmail.com designates 209.85.219.207 as permitted sender) Received: from [209.85.219.207] (HELO mail-ew0-f207.google.com) (209.85.219.207) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 Sep 2009 13:04:59 +0000 Received: by ewy3 with SMTP id 3so365884ewy.33 for ; Tue, 22 Sep 2009 06:04:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=6rKRDgGhs23/a5V6kiwqWKQRXqMFawjgsWe7GjAe/MM=; b=TOuIkDqK80Le9672qHaHT6u9C6Xq8WgEXd9h/yxzS5Z2HLF33zGW3ktJrI3YQ0Zt8r ETUp1qN5MEtVhb8mvOW5DNzogyflFgnQ26/go82Ao5SGoH10/MHhq3fLQTrZ75lhAnAa Af22fwEjok9HMa4zlJ0iavC3yucIS2hT8fbog= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=IQLyNmkTY41rkimL2uFDk1afKP0m4hWLX2ZhO6wrlBuyVvKS1RHGVj2ZL2zofuKKZD 179sKnN08SN/Utp0/0TZeiHOL+Fc1UdZFoYoVr2Mmm59KHYI0PcDbH1/dZUyHK2Y1iLp XeLH7a3T7qzz4zAqWSbwN874U0nZ/2P0gy2No= MIME-Version: 1.0 Received: by 10.216.56.82 with SMTP id l60mr225222wec.27.1253624678528; Tue, 22 Sep 2009 06:04:38 -0700 (PDT) In-Reply-To: <20090922125445.GB28443@ok2cons2.nine.ch> References: <25530494.post@talk.nabble.com> <20090922094732.GA6650@ok2cons2.nine.ch> <25aac9fc0909220510h462b6597gdaf2575660fbd1ff@mail.gmail.com> <20090922125445.GB28443@ok2cons2.nine.ch> Date: Tue, 22 Sep 2009 14:04:38 +0100 Message-ID: <25aac9fc0909220604i3d03920bybfa3db0e6d06d2cf@mail.gmail.com> Subject: Re: Last redirect URL From: sebb To: HttpComponents Project Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Checked: Checked by ClamAV on apache.org On 22/09/2009, Oleg Kalnichevski wrote: > On Tue, Sep 22, 2009 at 01:10:38PM +0100, sebb wrote: > > On 22/09/2009, Oleg Kalnichevski wrote: > > > On Mon, Sep 21, 2009 at 05:14:05PM -0700, Ken Krugler wrote: > > > > > > > > On Sep 21, 2009, at 2:30pm, droidin.net wrote: > > > > > > > >> > > > >> I have rather simple HttpClient 4 code that calls HttpGet to get HTML > > > >> output. > > > >> The HTML returns with scripts and image locations all set to local > > > >> (e.g. > > > >> /images/foo.jpg ) so I need calling URL to make these into absolute ( > > > >> http://foo.com/images/foo.jpg Now comes the problem - during the call > > > >> there > > > >> may be one or two 302 redirects so the original URL is no longer > > > >> reflects > > > >> the location of HTML. How do I get the latest URL of the returned > > > >> content > > > >> given all the redirects I may (or may not) have? > > > >> > > > >> I looked at HttpGet#getAllHeaders() and HttpResponse#getAllHeaders() - > > > >> couldn't find anything. > > > > > > > > From past posts on the list, I thought httpMethod.getURI() would return > > > > the final URL. > > > > > > > > -- Ken > > > > > > > > > > > > > > > > > Ken, > > > > > > This is only partially correct. The original request object remains unmodified. > > > > This is a change from 3.1; perhaps needs a note in the Javadoc to say > > it is not affected by redirects. > > > > > Sure. The question is where to put it. > I was thinking of the Javadoc for getURI() in the interface HttpUriRequest which is inherited by the implementing class(es). > > > > So, one needs to retrieve the internal HttpUriRequest and HttpHost objects from > > > the execution context in order to find out the final request URI / target host. > > > For details see: > > > > > > http://hc.apache.org/httpcomponents-client/tutorial/html/fundamentals.html#d4e205 > > > > Note that the text talks about 'http.target_host' but the code uses: > > > > ExecutionContext.HTTP_TARGET_HOST > > > > which is presumably a constant for the value. I think this is confusing. > > > > I assume the HC4 code actually uses constants throughout, so would IMO > > the document should do so too. > > > > Any objections to updating the documentation accordingly? > > > > > Certainly no objection from me, as long as the change is applied consistently > across the entire tutorial. OK, I'll have a look at what is involved. Are you OK with dropping the constant values from the docs? > Oleg > > > > I would prefer not to document the constant values (available via > > Javadoc anyway), i.e. I propose to change: > > > > * 'http.target_host': HttpHost instance representing the connection target. > > > > to > > > > * ExecutionContext.HTTP_TARGET_HOST: HttpHost instance representing > > the connection target. > > > > However, I suppose one could write: > > > > * ExecutionContext.HTTP_TARGET_HOST ('http.target_host'): HttpHost > > instance representing the connection target. > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org > > For additional commands, e-mail: dev-help@hc.apache.org > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org > For additional commands, e-mail: dev-help@hc.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org For additional commands, e-mail: dev-help@hc.apache.org