Esempio n. 1
0
 /** Adds valid Port attribute value, e.g. "8000,8001,8002" */
 @Override
 protected void formatCookieAsVer(
     final CharArrayBuffer buffer, final Cookie cookie, final int version) {
   super.formatCookieAsVer(buffer, cookie, version);
   // format port attribute
   if (cookie instanceof ClientCookie) {
     // Test if the port attribute as set by the origin server is not blank
     final String s = ((ClientCookie) cookie).getAttribute(ClientCookie.PORT_ATTR);
     if (s != null) {
       buffer.append("; $Port");
       buffer.append("=\"");
       if (s.trim().length() > 0) {
         final int[] ports = cookie.getPorts();
         if (ports != null) {
           final int len = ports.length;
           for (int i = 0; i < len; i++) {
             if (i > 0) {
               buffer.append(",");
             }
             buffer.append(Integer.toString(ports[i]));
           }
         }
       }
       buffer.append("\"");
     }
   }
 }
 public int[] getPorts() {
   return cookie.getPorts();
 }