View Javadoc
1 /* 2 * $Header: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpState.java,v 1.22.2.3 2003/10/29 03:08:49 mbecke Exp $ 3 * $Revision: 1.22.2.3 $ 4 * $Date: 2003/10/29 03:08:49 $ 5 * 6 * ==================================================================== 7 * 8 * The Apache Software License, Version 1.1 9 * 10 * Copyright (c) 1999-2003 The Apache Software Foundation. All rights 11 * reserved. 12 * 13 * Redistribution and use in source and binary forms, with or without 14 * modification, are permitted provided that the following conditions 15 * are met: 16 * 17 * 1. Redistributions of source code must retain the above copyright 18 * notice, this list of conditions and the following disclaimer. 19 * 20 * 2. Redistributions in binary form must reproduce the above copyright 21 * notice, this list of conditions and the following disclaimer in 22 * the documentation and/or other materials provided with the 23 * distribution. 24 * 25 * 3. The end-user documentation included with the redistribution, if 26 * any, must include the following acknowlegement: 27 * "This product includes software developed by the 28 * Apache Software Foundation (http://www.apache.org/)." 29 * Alternately, this acknowlegement may appear in the software itself, 30 * if and wherever such third-party acknowlegements normally appear. 31 * 32 * 4. The names "The Jakarta Project", "Commons", and "Apache Software 33 * Foundation" must not be used to endorse or promote products derived 34 * from this software without prior written permission. For written 35 * permission, please contact apache@apache.org. 36 * 37 * 5. Products derived from this software may not be called "Apache" 38 * nor may "Apache" appear in their names without prior written 39 * permission of the Apache Group. 40 * 41 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 42 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 43 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 44 * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR 45 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 46 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 47 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 48 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 49 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 50 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 51 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 52 * SUCH DAMAGE. 53 * ==================================================================== 54 * 55 * This software consists of voluntary contributions made by many 56 * individuals on behalf of the Apache Software Foundation. For more 57 * information on the Apache Software Foundation, please see 58 * <http://www.apache.org/>. 59 * 60 * [Additional notices, if required by prior licensing conditions] 61 * 62 */ 63 64 package org.apache.commons.httpclient; 65 66 import java.util.ArrayList; 67 import java.util.Date; 68 import java.util.HashMap; 69 import java.util.Map; 70 import java.util.List; 71 import java.util.Iterator; 72 import org.apache.commons.httpclient.cookie.CookieSpec; 73 import org.apache.commons.httpclient.cookie.CookiePolicy; 74 import org.apache.commons.httpclient.auth.HttpAuthRealm; 75 import org.apache.commons.logging.Log; 76 import org.apache.commons.logging.LogFactory; 77 78 /*** 79 * <p> 80 * A container for HTTP attributes that may persist from request 81 * to request, such as {@link Cookie cookies} and authentication 82 * {@link Credentials credentials}. 83 * </p> 84 * <p> 85 * Preemptive authentication can be turned on by using the property value of 86 * #PREEMPTIVE_PROPERTY. If left unspecified, it has the default value of 87 * #PREEMPTIVE_DEFAULT. This configurable behaviour conforms to rcf2617: 88 * </p> 89 * 90 * @author <a href="mailto:remm@apache.org">Remy Maucherat</a> 91 * @author Rodney Waldhoff 92 * @author <a href="mailto:jsdever@apache.org">Jeff Dever</a> 93 * @author Sean C. Sullivan 94 * @author <a href="mailto:becke@u.washington.edu">Michael Becke</a> 95 * @author <a href="mailto:oleg@ural.ru">Oleg Kalnichevski</a> 96 * @author <a href="mailto:mbowler@GargoyleSoftware.com">Mike Bowler</a> 97 * @author <a href="mailto:adrian@intencha.com">Adrian Sutton</a> 98 * 99 * @version $Revision: 1.22.2.3 $ $Date: 2003/10/29 03:08:49 $ 100 * 101 */ 102 public class HttpState { 103 104 // ----------------------------------------------------- Instance Variables 105 106 /*** 107 * Whether authentication should be attempted preemptively. 108 */ 109 private boolean preemptive; 110 111 /*** 112 * The boolean property name to turn on preemptive authentication. 113 */ 114 public static final String PREEMPTIVE_PROPERTY = 115 "httpclient.authentication.preemptive"; 116 117 /*** 118 * The default property value for #PREEMPTIVE_PROPERTY. 119 */ 120 public static final String PREEMPTIVE_DEFAULT = "false"; 121 122 /*** 123 * Map of {@link Credentials credentials} by realm that this 124 * HTTP state contains. 125 */ 126 private HashMap credMap = new HashMap(); 127 128 /*** 129 * Map of {@link Credentials proxy credentials} by realm that this 130 * HTTP state contains 131 */ 132 private HashMap proxyCred = new HashMap(); 133 134 /*** 135 * The default authentication realm. 136 */ 137 public static final HttpAuthRealm DEFAULT_AUTH_REALM = new HttpAuthRealm(null, null); 138 139 /*** 140 * Array of {@link Cookie cookies} that this HTTP state contains. 141 */ 142 private ArrayList cookies = new ArrayList(); 143 /*** 144 * Cookie policy that applies to this HTTP state. Default is 145 * {@link CookiePolicy#RFC2109} 146 */ 147 private int cookiePolicy = CookiePolicy.RFC2109; 148 149 /*** The current connection manager */ 150 private HttpConnectionManager httpConnectionManager; 151 152 // -------------------------------------------------------- Class Variables 153 154 /*** Log object for this class. */ 155 private static final Log LOG = LogFactory.getLog(HttpState.class); 156 157 /*** 158 * Default constructor. 159 */ 160 public HttpState() { 161 162 super(); 163 164 this.cookiePolicy = CookiePolicy.getDefaultPolicy(); 165 166 // check the preemptive policy 167 String preemptiveDefault = null; 168 try { 169 preemptiveDefault = System.getProperty(PREEMPTIVE_PROPERTY); 170 } catch (SecurityException ignore) { 171 } 172 if (preemptiveDefault == null) { 173 preemptiveDefault = PREEMPTIVE_DEFAULT; 174 } 175 preemptiveDefault = preemptiveDefault.trim().toLowerCase(); 176 177 if (!(preemptiveDefault.equals("true") 178 || preemptiveDefault.equals("false"))) { // property problem 179 LOG.warn("Configuration property " + PREEMPTIVE_PROPERTY 180 + " must be either true or false. Using default: " 181 + PREEMPTIVE_DEFAULT); 182 preemptiveDefault = PREEMPTIVE_DEFAULT; 183 } 184 this.preemptive = ("true".equals(preemptiveDefault)); 185 } 186 187 // ------------------------------------------------------------- Properties 188 189 /*** 190 * Adds an {@link Cookie HTTP cookie}, replacing any existing equivalent cookies. 191 * If the given cookie has already expired it will not be added, but existing 192 * values will still be removed. 193 * 194 * @param cookie the {@link Cookie cookie} to be added 195 * 196 * @see #addCookies(Cookie[]) 197 * 198 */ 199 public synchronized void addCookie(Cookie cookie) { 200 LOG.trace("enter HttpState.addCookie(Cookie)"); 201 202 if (cookie != null) { 203 // first remove any old cookie that is equivalent 204 for (Iterator it = cookies.iterator(); it.hasNext();) { 205 Cookie tmp = (Cookie) it.next(); 206 if (cookie.equals(tmp)) { 207 it.remove(); 208 break; 209 } 210 } 211 if (!cookie.isExpired()) { 212 cookies.add(cookie); 213 } 214 } 215 } 216 217 /*** 218 * Adds an array of {@link Cookie HTTP cookies}. Cookies are added individually and 219 * in the given array order. If any of the given cookies has already expired it will 220 * not be added, but existing values will still be removed. 221 * 222 * @param cookies the {@link Cookie cookies} to be added 223 * 224 * @see #addCookie(Cookie) 225 * 226 */ 227 public synchronized void addCookies(Cookie[] cookies) { 228 LOG.trace("enter HttpState.addCookies(Cookie[])"); 229 230 if (cookies != null) { 231 for (int i = 0; i < cookies.length; i++) { 232 this.addCookie(cookies[i]); 233 } 234 } 235 } 236 237 /*** 238 * Returns an array of {@link Cookie cookies} that this HTTP 239 * state currently contains. 240 * 241 * @return an array of {@link Cookie cookies}. 242 * 243 * @see #getCookies(String, int, String, boolean, java.util.Date) 244 * 245 */ 246 public synchronized Cookie[] getCookies() { 247 LOG.trace("enter HttpState.getCookies()"); 248 return (Cookie[]) (cookies.toArray(new Cookie[cookies.size()])); 249 } 250 251 /*** 252 * Returns an array of {@link Cookie cookies} in this HTTP 253 * state that match the given request parameters. 254 * 255 * @param domain the request domain 256 * @param port the request port 257 * @param path the request path 258 * @param secure <code>true</code> when using HTTPS 259 * @param now the {@link Date date} by which expiration is determined 260 * 261 * @return an array of {@link Cookie cookies}. 262 * 263 * @see #getCookies() 264 * 265 * @deprecated use CookieSpec#match(String, int, String, boolean, Cookie) 266 */ 267 public synchronized Cookie[] getCookies( 268 String domain, 269 int port, 270 String path, 271 boolean secure, 272 Date now 273 ) { 274 return getCookies(domain, port, path, secure); 275 } 276 277 278 /*** 279 * Returns an array of {@link Cookie cookies} in this HTTP 280 * state that match the given request parameters. 281 * 282 * @param domain the request domain 283 * @param port the request port 284 * @param path the request path 285 * @param secure <code>true</code> when using HTTPS 286 * 287 * @return an array of {@link Cookie cookies}. 288 * 289 * @see #getCookies() 290 * 291 * @deprecated use {@link CookieSpec#match(String, int, String, boolean, Cookie)} 292 */ 293 public synchronized Cookie[] getCookies( 294 String domain, 295 int port, 296 String path, 297 boolean secure 298 ) { 299 LOG.trace("enter HttpState.getCookies(String, int, String, boolean)"); 300 301 CookieSpec matcher = CookiePolicy.getDefaultSpec(); 302 ArrayList list = new ArrayList(cookies.size()); 303 for (int i = 0, m = cookies.size(); i < m; i++) { 304 Cookie cookie = (Cookie) (cookies.get(i)); 305 if (matcher.match(domain, port, path, secure, cookie)) { 306 list.add(cookie); 307 } 308 } 309 return (Cookie[]) (list.toArray(new Cookie[list.size()])); 310 } 311 312 /*** 313 * Removes all of {@link Cookie cookies} in this HTTP state 314 * that have expired according to the current system time. 315 * 316 * @see #purgeExpiredCookies(java.util.Date) 317 * 318 */ 319 public synchronized boolean purgeExpiredCookies() { 320 LOG.trace("enter HttpState.purgeExpiredCookies()"); 321 return purgeExpiredCookies(new Date()); 322 } 323 324 /*** 325 * Removes all of {@link Cookie cookies} in this HTTP state 326 * that have expired by the specified {@link java.util.Date date}. 327 * 328 * @param date The {@link java.util.Date date} to compare against. 329 * 330 * @return true if any cookies were purged. 331 * 332 * @see Cookie#isExpired(java.util.Date) 333 * 334 * @see #purgeExpiredCookies() 335 */ 336 public synchronized boolean purgeExpiredCookies(Date date) { 337 LOG.trace("enter HttpState.purgeExpiredCookies(Date)"); 338 boolean removed = false; 339 Iterator it = cookies.iterator(); 340 while (it.hasNext()) { 341 if (((Cookie) (it.next())).isExpired(date)) { 342 it.remove(); 343 removed = true; 344 } 345 } 346 return removed; 347 } 348 349 350 /*** 351 * Returns the current {@link CookiePolicy cookie policy} for this 352 * HTTP state. 353 * 354 * @return The {@link CookiePolicy cookie policy}. 355 */ 356 357 public int getCookiePolicy() { 358 return this.cookiePolicy; 359 } 360 361 362 /*** 363 * Defines whether preemptive authentication should be 364 * attempted. 365 * 366 * @param value <tt>true</tt> if preemptive authentication should be 367 * attempted, <tt>false</tt> otherwise. 368 */ 369 370 public void setAuthenticationPreemptive(boolean value) { 371 this.preemptive = value; 372 } 373 374 375 /*** 376 * Returns <tt>true</tt> if preemptive authentication should be 377 * attempted, <tt>false</tt> otherwise. 378 * 379 * @return boolean flag. 380 */ 381 382 public boolean isAuthenticationPreemptive() { 383 return this.preemptive; 384 } 385 386 387 /*** 388 * Sets the current {@link CookiePolicy cookie policy} for this HTTP 389 * state to one of the following supported policies: 390 * {@link CookiePolicy#COMPATIBILITY}, 391 * {@link CookiePolicy#NETSCAPE_DRAFT} or 392 * {@link CookiePolicy#RFC2109}. 393 * 394 * @param policy new {@link CookiePolicy cookie policy} 395 */ 396 397 public void setCookiePolicy(int policy) { 398 this.cookiePolicy = policy; 399 } 400 401 /*** 402 * Sets the {@link Credentials credentials} for the given authentication 403 * realm. The <code>null</code> realm signifies default credentials, which 404 * should be used when no {@link Credentials credentials} have been explictly 405 * supplied for the given challenging realm. Any previous credentials for 406 * the given realm will be overwritten. 407 * 408 * @deprecated This method does not distinguish between realms with the 409 * same name on different hosts. 410 * Use {@link #setCredentials(String, String, Credentials)} instead. 411 * 412 * @param realm the authentication realm 413 * @param credentials the authentication credentials for the given realm 414 * 415 * @see #getCredentials(String, String) 416 * @see #setProxyCredentials(String, String, Credentials) 417 */ 418 419 public synchronized void setCredentials(String realm, Credentials credentials) { 420 LOG.trace("enter HttpState.setCredentials(String, Credentials)"); 421 setCredentials(realm, null, credentials); 422 } 423 424 /*** 425 * Sets the {@link Credentials credentials} for the given authentication 426 * realm on the given host. The <code>null</code> realm signifies default 427 * credentials for the given host, which should be used when no 428 * {@link Credentials credentials} have been explictly supplied for the 429 * challenging realm. The <code>null</code> host signifies default 430 * credentials, which should be used when no {@link Credentials credentials} 431 * have been explictly supplied for the challenging host. Any previous 432 * credentials for the given realm on the given host will be overwritten. 433 * 434 * @param realm the authentication realm 435 * @param host the host the realm belongs to 436 * @param credentials the authentication {@link Credentials credentials} 437 * for the given realm. 438 * 439 * @see #getCredentials(String, String) 440 * @see #setProxyCredentials(String, String, Credentials) 441 */ 442 443 public synchronized void setCredentials(String realm, String host, Credentials credentials) { 444 LOG.trace( 445 "enter HttpState.setCredentials(String realm, String host, Credentials credentials)"); 446 credMap.put(new HttpAuthRealm(host, realm), credentials); 447 } 448 449 450 /*** 451 * Find matching {@link Credentials credentials} for the given authentication realm and host. 452 * 453 * If the <i>realm</i> exists on <i>host</i>, return the coresponding credentials. 454 * If the <i>host</i> exists with a <tt>null</tt> <i>realm</i>, return the corresponding 455 * credentials. 456 * If the <i>realm</i> exists with a <tt>null</tt> <i>host</i>, return the 457 * corresponding credentials. If the <i>realm</i> does not exist, return 458 * the default Credentials. If there are no default credentials, return 459 * <code>null</code>. 460 * 461 * @param map the credentials hash map 462 * @param realm the authentication realm 463 * @param host the host the realm is on 464 * @return the credentials 465 * 466 */ 467 private static Credentials matchCredentials(HashMap map, String realm, String host) { 468 HttpAuthRealm entry = new HttpAuthRealm(host, realm); 469 Credentials creds = (Credentials) map.get(entry); 470 if (creds == null && host != null && realm != null) { 471 entry = new HttpAuthRealm(host, null); 472 creds = (Credentials) map.get(entry); 473 if (creds == null) { 474 entry = new HttpAuthRealm(null, realm); 475 creds = (Credentials) map.get(entry); 476 } 477 } 478 if (creds == null) { 479 creds = (Credentials) map.get(DEFAULT_AUTH_REALM); 480 } 481 return creds; 482 } 483 484 /*** 485 * Get the {@link Credentials credentials} for the given authentication realm on the 486 * given host. 487 * 488 * If the <i>realm</i> exists on <i>host</i>, return the coresponding credentials. 489 * If the <i>host</i> exists with a <tt>null</tt> <i>realm</i>, return the corresponding 490 * credentials. 491 * If the <i>realm</i> exists with a <tt>null</tt> <i>host</i>, return the 492 * corresponding credentials. If the <i>realm</i> does not exist, return 493 * the default Credentials. If there are no default credentials, return 494 * <code>null</code>. 495 * 496 * @param realm the authentication realm 497 * @param host the host the realm is on 498 * @return the credentials 499 * 500 * @see #setCredentials(String, String, Credentials) 501 */ 502 503 public synchronized Credentials getCredentials(String realm, String host) { 504 LOG.trace("enter HttpState.getCredentials(String, String"); 505 return matchCredentials(this.credMap, realm, host); 506 } 507 508 /*** 509 * Get the {@link Credentials credentials} for the given authentication realm. 510 * 511 * @deprecated This method does not distinguish between realms on different 512 * servers with the same name. Use {@link #getCredentials(String, String)} 513 * instead. 514 * 515 * @param realm the authentication realm 516 * @return the credentials 517 * 518 * @see #setCredentials(String, String, Credentials) 519 * 520 */ 521 522 public synchronized Credentials getCredentials(String realm) { 523 LOG.trace("enter HttpState.getCredentials(String)"); 524 525 return getCredentials(realm, null); 526 } 527 528 /*** 529 * Sets the {@link Credentials credentials} for the given proxy authentication 530 * realm. The <code>null</code> realm signifies default credentials, which 531 * should be used when no {@link Credentials credentials} have been explictly 532 * supplied for the given challenging proxy realm. Any previous credentials for 533 * the given realm will be overwritten. 534 * 535 * @deprecated This method does not differentiate between realms with 536 * the same name on different servers. Use 537 * {@link #setProxyCredentials(String, String, Credentials)} instead. 538 * 539 * @param realm the authentication realm 540 * @param credentials the authentication credentials for the given realm 541 * 542 * @see #getProxyCredentials(String) 543 * @see #setCredentials(String, Credentials) 544 * 545 */ 546 547 public synchronized void setProxyCredentials(String realm, Credentials credentials) { 548 LOG.trace("enter HttpState.setProxyCredentials(String, credentials)"); 549 setProxyCredentials(realm, null, credentials); 550 } 551 552 /*** 553 * Sets the {@link Credentials credentials} for the given proxy authentication 554 * realm on the given proxy host. The <code>null</code> proxy realm signifies 555 * default credentials for the given proxy host, which should be used when no 556 * {@link Credentials credentials} have been explictly supplied for the 557 * challenging proxy realm. The <code>null</code> proxy host signifies default 558 * credentials, which should be used when no {@link Credentials credentials} 559 * have been explictly supplied for the challenging proxy host. Any previous 560 * credentials for the given proxy realm on the given proxy host will be 561 * overwritten. 562 * 563 * @param realm the authentication realm 564 * @param proxyHost the proxy host 565 * @param credentials the authentication credentials for the given realm 566 * 567 * @see #getProxyCredentials(String) 568 * @see #setCredentials(String, Credentials) 569 * 570 */ 571 public synchronized void setProxyCredentials( 572 String realm, 573 String proxyHost, 574 Credentials credentials 575 ) { 576 LOG.trace("enter HttpState.setProxyCredentials(String, String, Credentials"); 577 proxyCred.put(new HttpAuthRealm(proxyHost, realm), credentials); 578 } 579 580 /*** 581 * Get the {@link Credentials credentials} for the given 582 * proxy authentication realm. 583 * 584 * If the <i>realm</i> exists, return the coresponding credentials. If the 585 * <i>realm</i> does not exist, return the default Credentials. If there is 586 * no default credentials, return <code>null</code>. 587 * 588 * @deprecated This method does not distinguish between realms on different hosts. 589 * Use {@link #getProxyCredentials(String, String)} instead. 590 * 591 * @param realm the authentication realm 592 * @return the credentials 593 * @see #setProxyCredentials(String, String, Credentials) 594 */ 595 596 public synchronized Credentials getProxyCredentials(String realm) { 597 LOG.trace("enter HttpState.getProxyCredentials(String)"); 598 return getProxyCredentials(realm, null); 599 } 600 601 /*** 602 * Get the {@link Credentials credentials} for the proxy host with the given 603 * authentication realm. 604 * 605 * If the <i>realm</i> exists on <i>host</i>, return the coresponding credentials. 606 * If the <i>host</i> exists with a <tt>null</tt> <i>realm</i>, return the corresponding 607 * credentials. 608 * If the <i>realm</i> exists with a <tt>null</tt> <i>host</i>, return the 609 * corresponding credentials. If the <i>realm</i> does not exist, return 610 * the default Credentials. If there are no default credentials, return 611 * <code>null</code>. 612 * 613 * @param realm the authentication realm 614 * @param proxyHost the proxy host the realm is on 615 * @return the credentials 616 * @see #setProxyCredentials(String, String, Credentials) 617 */ 618 public synchronized Credentials getProxyCredentials(String realm, String proxyHost) { 619 LOG.trace("enter HttpState.getCredentials(String, String"); 620 return matchCredentials(this.proxyCred, realm, proxyHost); 621 } 622 623 /*** 624 * Returns a string representation of this HTTP state. 625 * 626 * @return The string representation of the HTTP state. 627 * 628 * @see java.lang.Object#toString() 629 */ 630 public synchronized String toString() { 631 StringBuffer sbResult = new StringBuffer(); 632 633 sbResult.append("["); 634 sbResult.append(getProxyCredentialsStringRepresentation(proxyCred)); 635 sbResult.append(" | "); 636 sbResult.append(getCredentialsStringRepresentation(proxyCred)); 637 sbResult.append(" | "); 638 sbResult.append(getCookiesStringRepresentation(cookies)); 639 sbResult.append("]"); 640 641 String strResult = sbResult.toString(); 642 643 return strResult; 644 } 645 646 /*** 647 * Returns a string representation of the proxy credentials 648 * @param proxyCredMap The proxy credentials 649 * @return The string representation. 650 */ 651 private static String getProxyCredentialsStringRepresentation(final Map proxyCredMap) { 652 StringBuffer sbResult = new StringBuffer(); 653 Iterator iter = proxyCredMap.keySet().iterator(); 654 while (iter.hasNext()) { 655 Object key = iter.next(); 656 Credentials cred = (Credentials) proxyCredMap.get(key); 657 if (sbResult.length() > 0) { 658 sbResult.append(", "); 659 } 660 sbResult.append(key); 661 sbResult.append("#"); 662 sbResult.append(cred.toString()); 663 } 664 return sbResult.toString(); 665 } 666 667 /*** 668 * Returns a string representation of the credentials. 669 * @param credMap The credentials. 670 * @return The string representation. 671 */ 672 private static String getCredentialsStringRepresentation(final Map credMap) { 673 StringBuffer sbResult = new StringBuffer(); 674 Iterator iter = credMap.keySet().iterator(); 675 while (iter.hasNext()) { 676 Object key = iter.next(); 677 Credentials cred = (Credentials) credMap.get(key); 678 if (sbResult.length() > 0) { 679 sbResult.append(", "); 680 } 681 sbResult.append(key); 682 sbResult.append("#"); 683 sbResult.append(cred.toString()); 684 } 685 return sbResult.toString(); 686 } 687 688 /*** 689 * Return a string representation of the cookies. 690 * @param cookies The cookies 691 * @return The string representation. 692 */ 693 private static String getCookiesStringRepresentation(final List cookies) { 694 StringBuffer sbResult = new StringBuffer(); 695 Iterator iter = cookies.iterator(); 696 while (iter.hasNext()) { 697 Cookie ck = (Cookie) iter.next(); 698 if (sbResult.length() > 0) { 699 sbResult.append("#"); 700 } 701 sbResult.append(ck.toExternalForm()); 702 } 703 return sbResult.toString(); 704 } 705 706 /*** 707 * Returns the httpConnectionManager. 708 * @return HttpConnectionManager 709 * 710 * @deprecated Connection manager is controlled by the HttpClient class. 711 * Use {@link HttpClient#getHttpConnectionManager()} instead. 712 * 713 * @since 2.0 714 */ 715 public synchronized HttpConnectionManager getHttpConnectionManager() { 716 return httpConnectionManager; 717 } 718 719 /*** 720 * Sets the httpConnectionManager. 721 * @param httpConnectionManager The httpConnectionManager to set 722 * 723 * @deprecated Connection manager is controlled by the HttpClient class. 724 * Use {@link HttpClient#setHttpConnectionManager(HttpConnectionManager)} instead. 725 * 726 * @since 2.0 727 */ 728 public synchronized void setHttpConnectionManager( 729 HttpConnectionManager httpConnectionManager 730 ) { 731 this.httpConnectionManager = httpConnectionManager; 732 } 733 }

This page was automatically generated by Maven