comparison src/org/eclipse/jetty/server/Request.java @ 997:7d28be82ab75

simplify Request
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 18 Oct 2016 22:43:17 -0600
parents 4e9d373bf6e9
children bf176925e00f
comparison
equal deleted inserted replaced
996:d9cfec64899c 997:7d28be82ab75
120 * 120 *
121 * 121 *
122 */ 122 */
123 public final class Request implements HttpServletRequest 123 public final class Request implements HttpServletRequest
124 { 124 {
125 public static final String __MULTIPART_CONFIG_ELEMENT = "org.eclipse.multipartConfig";
126 public static final String __MULTIPART_INPUT_STREAM = "org.eclipse.multiPartInputStream";
127 public static final String __MULTIPART_CONTEXT = "org.eclipse.multiPartContext";
128 private static final Logger LOG = LoggerFactory.getLogger(Request.class); 125 private static final Logger LOG = LoggerFactory.getLogger(Request.class);
129 126
130 private static final String __ASYNC_FWD = "org.eclipse.asyncfwd";
131 private static final Collection __defaultLocale = Collections.singleton(Locale.getDefault()); 127 private static final Collection __defaultLocale = Collections.singleton(Locale.getDefault());
132 private static final int __NONE = 0, _STREAM = 1, __READER = 2; 128 private static final int __NONE = 0, _STREAM = 1, __READER = 2;
133 129
134 private volatile Attributes _attributes; 130 private volatile Attributes _attributes;
135 private MultiMap<String> _baseParameters; 131 private MultiMap<String> _baseParameters;
136 private String _characterEncoding; 132 private String _characterEncoding;
137 protected AbstractHttpConnection _connection; 133 protected final AbstractHttpConnection _connection;
138 public ContextHandler _contextHandler = null; 134 public ContextHandler _contextHandler = null;
139 private String _contextPath; 135 private String _contextPath;
140 private CookieCutter _cookies; 136 private CookieCutter _cookies;
141 private boolean _cookiesExtracted = false; 137 private boolean _cookiesExtracted = false;
142 private EndPoint _endp; 138 private final EndPoint _endp;
143 private boolean _handled = false; 139 private boolean _handled = false;
144 private int _inputState = __NONE; 140 private int _inputState = __NONE;
145 private String _method; 141 private String _method;
146 private MultiMap<String> _parameters; 142 private MultiMap<String> _parameters;
147 private boolean _paramsExtracted; 143 private boolean _paramsExtracted;
149 private int _port; 145 private int _port;
150 private String _protocol = HttpVersions.HTTP_1_1; 146 private String _protocol = HttpVersions.HTTP_1_1;
151 private String _queryString; 147 private String _queryString;
152 private BufferedReader _reader; 148 private BufferedReader _reader;
153 private String _readerEncoding; 149 private String _readerEncoding;
154 private String _remoteAddr;
155 private String _remoteHost;
156 private String _requestURI; 150 private String _requestURI;
157 private String _scheme = URIUtil.HTTP; 151 private String _scheme = URIUtil.HTTP;
158 private String _serverName; 152 private String _serverName;
159 private String _servletPath;
160 private long _timeStamp; 153 private long _timeStamp;
161 private long _dispatchTime; 154
162
163 private Buffer _timeStampBuffer;
164 private HttpURI _uri; 155 private HttpURI _uri;
165 156
166 /* ------------------------------------------------------------ */
167 public Request()
168 {
169 }
170
171 /* ------------------------------------------------------------ */
172 public Request(AbstractHttpConnection connection) 157 public Request(AbstractHttpConnection connection)
173 { 158 {
174 setConnection(connection); 159 _connection = connection;
160 _endp = connection.getEndPoint();
175 } 161 }
176 162
177 /* ------------------------------------------------------------ */ 163 /* ------------------------------------------------------------ */
178 /** 164 /**
179 * Extract Parameters from query string and/or form _content. 165 * Extract Parameters from query string and/or form _content.
180 */ 166 */
181 public void extractParameters() 167 private void extractParameters()
182 { 168 {
183 if (_baseParameters == null) 169 if (_baseParameters == null)
184 _baseParameters = new MultiMap(16); 170 _baseParameters = new MultiMap(16);
185 171
186 if (_paramsExtracted) 172 if (_paramsExtracted)
262 Object values = entry.getValue(); 248 Object values = entry.getValue();
263 for (int i = 0; i < LazyList.size(values); i++) 249 for (int i = 0; i < LazyList.size(values); i++)
264 _parameters.add(name,LazyList.get(values,i)); 250 _parameters.add(name,LazyList.get(values,i));
265 } 251 }
266 } 252 }
267
268 if (content_type != null && content_type.length()>0 && content_type.startsWith("multipart/form-data") && getAttribute(__MULTIPART_CONFIG_ELEMENT)!=null)
269 {
270 try
271 {
272 getParts();
273 }
274 catch (IOException e)
275 {
276 if (LOG.isDebugEnabled())
277 LOG.warn("",e);
278 else
279 LOG.warn(e.toString());
280 }
281 catch (ServletException e)
282 {
283 if (LOG.isDebugEnabled())
284 LOG.warn("",e);
285 else
286 LOG.warn(e.toString());
287 }
288 }
289 } 253 }
290 finally 254 finally
291 { 255 {
292 // ensure params always set (even if empty) after extraction 256 // ensure params always set (even if empty) after extraction
293 if (_parameters == null) 257 if (_parameters == null)
294 _parameters = _baseParameters; 258 _parameters = _baseParameters;
295 } 259 }
296 } 260 }
297 261
298 /* ------------------------------------------------------------ */ 262 @Override
299 public AsyncContext getAsyncContext() 263 public AsyncContext getAsyncContext()
300 { 264 {
301 throw new UnsupportedOperationException(); 265 throw new UnsupportedOperationException();
302 } 266 }
303 267
304 /* ------------------------------------------------------------ */ 268 @Override
305 /*
306 * @see javax.servlet.ServletRequest#getAttribute(java.lang.String)
307 */
308 public Object getAttribute(String name) 269 public Object getAttribute(String name)
309 { 270 {
310 if ("org.eclipse.jetty.io.EndPoint.maxIdleTime".equalsIgnoreCase(name)) 271 return (_attributes == null)?null:_attributes.getAttribute(name);
311 return new Long(getConnection().getEndPoint().getMaxIdleTime()); 272 }
312 273
313 Object attr = (_attributes == null)?null:_attributes.getAttribute(name); 274 @Override
314 return attr;
315 }
316
317 /* ------------------------------------------------------------ */
318 /*
319 * @see javax.servlet.ServletRequest#getAttributeNames()
320 */
321 public Enumeration getAttributeNames() 275 public Enumeration getAttributeNames()
322 { 276 {
323 if (_attributes == null) 277 if (_attributes == null)
324 return Collections.enumeration(Collections.EMPTY_LIST); 278 return Collections.enumeration(Collections.EMPTY_LIST);
325 279
326 return AttributesMap.getAttributeNamesCopy(_attributes); 280 return AttributesMap.getAttributeNamesCopy(_attributes);
327 } 281 }
328 282
329 /* ------------------------------------------------------------ */ 283 @Override
330 /*
331 */
332 public Attributes getAttributes()
333 {
334 if (_attributes == null)
335 _attributes = new AttributesMap();
336 return _attributes;
337 }
338
339 /* ------------------------------------------------------------ */
340 /*
341 * @see javax.servlet.http.HttpServletRequest#getAuthType()
342 */
343 public String getAuthType() 284 public String getAuthType()
344 { 285 {
345 return null; 286 return null;
346 } 287 }
347 288
348 /* ------------------------------------------------------------ */ 289 @Override
349 /*
350 * @see javax.servlet.ServletRequest#getCharacterEncoding()
351 */
352 public String getCharacterEncoding() 290 public String getCharacterEncoding()
353 { 291 {
354 return _characterEncoding; 292 return _characterEncoding;
355 } 293 }
356 294
357 /* ------------------------------------------------------------ */ 295 @Override
358 /**
359 * @return Returns the connection.
360 */
361 public AbstractHttpConnection getConnection()
362 {
363 return _connection;
364 }
365
366 /* ------------------------------------------------------------ */
367 /*
368 * @see javax.servlet.ServletRequest#getContentLength()
369 */
370 public int getContentLength() 296 public int getContentLength()
371 { 297 {
372 return (int)_connection._requestFields.getLongField(HttpHeaders.CONTENT_LENGTH_BUFFER); 298 return (int)_connection._requestFields.getLongField(HttpHeaders.CONTENT_LENGTH_BUFFER);
373 } 299 }
374 300
375 public long getContentRead() 301 @Override
376 {
377 if (_connection == null)
378 return -1;
379
380 return _connection._parser.getContentRead();
381 }
382
383 /* ------------------------------------------------------------ */
384 /*
385 * @see javax.servlet.ServletRequest#getContentType()
386 */
387 public String getContentType() 302 public String getContentType()
388 { 303 {
389 return _connection._requestFields.getStringField(HttpHeaders.CONTENT_TYPE_BUFFER); 304 return _connection._requestFields.getStringField(HttpHeaders.CONTENT_TYPE_BUFFER);
390 } 305 }
391 306
392 /* ------------------------------------------------------------ */ 307 @Override
393 /*
394 * @see javax.servlet.http.HttpServletRequest#getContextPath()
395 */
396 public String getContextPath() 308 public String getContextPath()
397 { 309 {
398 return _contextPath; 310 return _contextPath;
399 } 311 }
400 312
401 /* ------------------------------------------------------------ */ 313 @Override
402 /*
403 * @see javax.servlet.http.HttpServletRequest#getCookies()
404 */
405 public Cookie[] getCookies() 314 public Cookie[] getCookies()
406 { 315 {
407 if (_cookiesExtracted) 316 if (_cookiesExtracted)
408 return _cookies == null?null:_cookies.getCookies(); 317 return _cookies == null?null:_cookies.getCookies();
409 318
425 } 334 }
426 335
427 return _cookies == null?null:_cookies.getCookies(); 336 return _cookies == null?null:_cookies.getCookies();
428 } 337 }
429 338
430 /* ------------------------------------------------------------ */ 339 @Override
431 /*
432 * @see javax.servlet.http.HttpServletRequest#getDateHeader(java.lang.String)
433 */
434 public long getDateHeader(String name) 340 public long getDateHeader(String name)
435 { 341 {
436 return _connection._requestFields.getDateField(name); 342 return _connection._requestFields.getDateField(name);
437 } 343 }
438 344
440 public DispatcherType getDispatcherType() 346 public DispatcherType getDispatcherType()
441 { 347 {
442 throw new UnsupportedOperationException(); 348 throw new UnsupportedOperationException();
443 } 349 }
444 350
445 /* ------------------------------------------------------------ */ 351 @Override
446 /*
447 * @see javax.servlet.http.HttpServletRequest#getHeader(java.lang.String)
448 */
449 public String getHeader(String name) 352 public String getHeader(String name)
450 { 353 {
451 return _connection._requestFields.getStringField(name); 354 return _connection._requestFields.getStringField(name);
452 } 355 }
453 356
454 /* ------------------------------------------------------------ */ 357 @Override
455 /*
456 * @see javax.servlet.http.HttpServletRequest#getHeaderNames()
457 */
458 public Enumeration getHeaderNames() 358 public Enumeration getHeaderNames()
459 { 359 {
460 return _connection._requestFields.getFieldNames(); 360 return _connection._requestFields.getFieldNames();
461 } 361 }
462 362
463 /* ------------------------------------------------------------ */ 363 @Override
464 /*
465 * @see javax.servlet.http.HttpServletRequest#getHeaders(java.lang.String)
466 */
467 public Enumeration getHeaders(String name) 364 public Enumeration getHeaders(String name)
468 { 365 {
469 Enumeration e = _connection._requestFields.getValues(name); 366 Enumeration e = _connection._requestFields.getValues(name);
470 if (e == null) 367 if (e == null)
471 return Collections.enumeration(Collections.EMPTY_LIST); 368 return Collections.enumeration(Collections.EMPTY_LIST);
472 return e; 369 return e;
473 } 370 }
474 371
475 /* ------------------------------------------------------------ */ 372 @Override
476 /**
477 * @return Returns the inputState.
478 */
479 public int getInputState()
480 {
481 return _inputState;
482 }
483
484 /* ------------------------------------------------------------ */
485 /*
486 * @see javax.servlet.ServletRequest#getInputStream()
487 */
488 public ServletInputStream getInputStream() throws IOException 373 public ServletInputStream getInputStream() throws IOException
489 { 374 {
490 if (_inputState != __NONE && _inputState != _STREAM) 375 if (_inputState != __NONE && _inputState != _STREAM)
491 throw new IllegalStateException("READER"); 376 throw new IllegalStateException("READER");
492 _inputState = _STREAM; 377 _inputState = _STREAM;
493 return _connection.getInputStream(); 378 return _connection.getInputStream();
494 } 379 }
495 380
496 /* ------------------------------------------------------------ */ 381 @Override
497 /*
498 * @see javax.servlet.http.HttpServletRequest#getIntHeader(java.lang.String)
499 */
500 public int getIntHeader(String name) 382 public int getIntHeader(String name)
501 { 383 {
502 return (int)_connection._requestFields.getLongField(name); 384 return (int)_connection._requestFields.getLongField(name);
503 } 385 }
504 386
505 /* ------------------------------------------------------------ */ 387 @Override
506 /*
507 * @see javax.servlet.ServletRequest#getLocalAddr()
508 */
509 public String getLocalAddr() 388 public String getLocalAddr()
510 { 389 {
511 return _endp == null?null:_endp.getLocalAddr(); 390 return _endp.getLocalAddr();
512 } 391 }
513 392
514 /* ------------------------------------------------------------ */ 393 @Override
515 /*
516 * @see javax.servlet.ServletRequest#getLocale()
517 */
518 public Locale getLocale() 394 public Locale getLocale()
519 { 395 {
520 Enumeration enm = _connection._requestFields.getValues( "Accept-Language", ", \t" ); 396 Enumeration enm = _connection._requestFields.getValues( "Accept-Language", ", \t" );
521 397
522 // handle no locale 398 // handle no locale
545 } 421 }
546 422
547 return Locale.getDefault(); 423 return Locale.getDefault();
548 } 424 }
549 425
550 /* ------------------------------------------------------------ */ 426 @Override
551 /*
552 * @see javax.servlet.ServletRequest#getLocales()
553 */
554 public Enumeration getLocales() 427 public Enumeration getLocales()
555 { 428 {
556 429
557 Enumeration enm = _connection._requestFields.getValues( "Accept-Language", ", \t" ); 430 Enumeration enm = _connection._requestFields.getValues( "Accept-Language", ", \t" );
558 431
589 return Collections.enumeration(__defaultLocale); 462 return Collections.enumeration(__defaultLocale);
590 463
591 return Collections.enumeration(LazyList.getList(langs)); 464 return Collections.enumeration(LazyList.getList(langs));
592 } 465 }
593 466
594 /* ------------------------------------------------------------ */ 467 @Override
595 /*
596 * @see javax.servlet.ServletRequest#getLocalName()
597 */
598 public String getLocalName() 468 public String getLocalName()
599 { 469 {
600 if (_endp == null)
601 return null;
602
603 String local = _endp.getLocalAddr(); 470 String local = _endp.getLocalAddr();
604 if (local != null && local.indexOf(':') >= 0) 471 if (local != null && local.indexOf(':') >= 0)
605 local = "[" + local + "]"; 472 local = "[" + local + "]";
606 return local; 473 return local;
607 } 474 }
608 475
609 /* ------------------------------------------------------------ */ 476 @Override
610 /*
611 * @see javax.servlet.ServletRequest#getLocalPort()
612 */
613 public int getLocalPort() 477 public int getLocalPort()
614 { 478 {
615 return _endp == null?0:_endp.getLocalPort(); 479 return _endp.getLocalPort();
616 } 480 }
617 481
618 /* ------------------------------------------------------------ */ 482 @Override
619 /*
620 * @see javax.servlet.http.HttpServletRequest#getMethod()
621 */
622 public String getMethod() 483 public String getMethod()
623 { 484 {
624 return _method; 485 return _method;
625 } 486 }
626 487
627 /* ------------------------------------------------------------ */ 488 @Override
628 /*
629 * @see javax.servlet.ServletRequest#getParameter(java.lang.String)
630 */
631 public String getParameter(String name) 489 public String getParameter(String name)
632 { 490 {
633 if (!_paramsExtracted) 491 if (!_paramsExtracted)
634 extractParameters(); 492 extractParameters();
635 return (String)_parameters.getValue(name,0); 493 return (String)_parameters.getValue(name,0);
636 } 494 }
637 495
638 /* ------------------------------------------------------------ */ 496 @Override
639 /*
640 * @see javax.servlet.ServletRequest#getParameterMap()
641 */
642 public Map getParameterMap() 497 public Map getParameterMap()
643 { 498 {
644 if (!_paramsExtracted) 499 if (!_paramsExtracted)
645 extractParameters(); 500 extractParameters();
646 501
647 return Collections.unmodifiableMap(_parameters.toStringArrayMap()); 502 return Collections.unmodifiableMap(_parameters.toStringArrayMap());
648 } 503 }
649 504
650 /* ------------------------------------------------------------ */ 505 @Override
651 /*
652 * @see javax.servlet.ServletRequest#getParameterNames()
653 */
654 public Enumeration getParameterNames() 506 public Enumeration getParameterNames()
655 { 507 {
656 if (!_paramsExtracted) 508 if (!_paramsExtracted)
657 extractParameters(); 509 extractParameters();
658 return Collections.enumeration(_parameters.keySet()); 510 return Collections.enumeration(_parameters.keySet());
659 } 511 }
660 512
661 /* ------------------------------------------------------------ */ 513 @Override
662 /**
663 * @return Returns the parameters.
664 */
665 public MultiMap<String> getParameters()
666 {
667 return _parameters;
668 }
669
670 /* ------------------------------------------------------------ */
671 /*
672 * @see javax.servlet.ServletRequest#getParameterValues(java.lang.String)
673 */
674 public String[] getParameterValues(String name) 514 public String[] getParameterValues(String name)
675 { 515 {
676 if (!_paramsExtracted) 516 if (!_paramsExtracted)
677 extractParameters(); 517 extractParameters();
678 List<Object> vals = _parameters.getValues(name); 518 List<Object> vals = _parameters.getValues(name);
679 if (vals == null) 519 if (vals == null)
680 return null; 520 return null;
681 return vals.toArray(new String[vals.size()]); 521 return vals.toArray(new String[vals.size()]);
682 } 522 }
683 523
684 /* ------------------------------------------------------------ */ 524 @Override
685 /*
686 * @see javax.servlet.http.HttpServletRequest#getPathInfo()
687 */
688 public String getPathInfo() 525 public String getPathInfo()
689 { 526 {
690 return _pathInfo; 527 return _pathInfo;
691 } 528 }
692 529
694 public String getPathTranslated() 531 public String getPathTranslated()
695 { 532 {
696 return null; 533 return null;
697 } 534 }
698 535
699 /* ------------------------------------------------------------ */ 536 @Override
700 /*
701 * @see javax.servlet.ServletRequest#getProtocol()
702 */
703 public String getProtocol() 537 public String getProtocol()
704 { 538 {
705 return _protocol; 539 return _protocol;
706 } 540 }
707 541
708 /* ------------------------------------------------------------ */ 542 @Override
709 /*
710 * @see javax.servlet.http.HttpServletRequest#getQueryString()
711 */
712 public String getQueryString() 543 public String getQueryString()
713 { 544 {
714 if (_queryString == null && _uri != null) 545 if (_queryString == null && _uri != null)
715 { 546 {
716 _queryString = _uri.getQuery(); 547 _queryString = _uri.getQuery();
717 } 548 }
718 return _queryString; 549 return _queryString;
719 } 550 }
720 551
721 /* ------------------------------------------------------------ */ 552 @Override
722 /*
723 * @see javax.servlet.ServletRequest#getReader()
724 */
725 public BufferedReader getReader() throws IOException 553 public BufferedReader getReader() throws IOException
726 { 554 {
727 if (_inputState != __NONE && _inputState != __READER) 555 if (_inputState != __NONE && _inputState != __READER)
728 throw new IllegalStateException("STREAMED"); 556 throw new IllegalStateException("STREAMED");
729 557
755 public String getRealPath(String path) 583 public String getRealPath(String path)
756 { 584 {
757 return null; 585 return null;
758 } 586 }
759 587
760 /* ------------------------------------------------------------ */ 588 @Override
761 /*
762 * @see javax.servlet.ServletRequest#getRemoteAddr()
763 */
764 public String getRemoteAddr() 589 public String getRemoteAddr()
765 { 590 {
766 if (_remoteAddr != null) 591 return _endp.getRemoteAddr();
767 return _remoteAddr; 592 }
768 return _endp == null?null:_endp.getRemoteAddr(); 593
769 } 594 @Override
770
771 /* ------------------------------------------------------------ */
772 /*
773 * @see javax.servlet.ServletRequest#getRemoteHost()
774 */
775 public String getRemoteHost() 595 public String getRemoteHost()
776 { 596 {
777 return getRemoteAddr(); 597 return getRemoteAddr();
778 } 598 }
779 599
780 /* ------------------------------------------------------------ */ 600 @Override
781 /*
782 * @see javax.servlet.ServletRequest#getRemotePort()
783 */
784 public int getRemotePort() 601 public int getRemotePort()
785 { 602 {
786 return _endp == null?0:_endp.getRemotePort(); 603 return _endp.getRemotePort();
787 } 604 }
788 605
789 /* ------------------------------------------------------------ */ 606 @Override
790 /*
791 * @see javax.servlet.http.HttpServletRequest#getRemoteUser()
792 */
793 public String getRemoteUser() 607 public String getRemoteUser()
794 { 608 {
795 Principal p = getUserPrincipal(); 609 return null;
796 if (p == null)
797 return null;
798 return p.getName();
799 } 610 }
800 611
801 @Override 612 @Override
802 public RequestDispatcher getRequestDispatcher(String path) 613 public RequestDispatcher getRequestDispatcher(String path)
803 { 614 {
804 throw new UnsupportedOperationException(); 615 throw new UnsupportedOperationException();
805 } 616 }
806 617
807 /* ------------------------------------------------------------ */ 618 @Override
808 /*
809 * @see javax.servlet.http.HttpServletRequest#getRequestedSessionId()
810 */
811 public String getRequestedSessionId() 619 public String getRequestedSessionId()
812 { 620 {
813 throw new UnsupportedOperationException(); 621 throw new UnsupportedOperationException();
814 } 622 }
815 623
816 /* ------------------------------------------------------------ */ 624 @Override
817 /*
818 * @see javax.servlet.http.HttpServletRequest#getRequestURI()
819 */
820 public String getRequestURI() 625 public String getRequestURI()
821 { 626 {
822 if (_requestURI == null && _uri != null) 627 if (_requestURI == null && _uri != null)
823 _requestURI = _uri.getPathAndParam(); 628 _requestURI = _uri.getPathAndParam();
824 return _requestURI; 629 return _requestURI;
825 } 630 }
826 631
827 /* ------------------------------------------------------------ */ 632 @Override
828 /*
829 * @see javax.servlet.http.HttpServletRequest#getRequestURL()
830 */
831 public StringBuffer getRequestURL() 633 public StringBuffer getRequestURL()
832 { 634 {
833 final StringBuffer url = new StringBuffer(48); 635 final StringBuffer url = new StringBuffer(48);
834 synchronized (url) 636 synchronized (url)
835 { 637 {
846 } 648 }
847 649
848 url.append(getRequestURI()); 650 url.append(getRequestURI());
849 return url; 651 return url;
850 } 652 }
851 }
852
853 /* ------------------------------------------------------------ */
854 public Response getResponse()
855 {
856 return _connection._response;
857 } 653 }
858 654
859 /* ------------------------------------------------------------ */ 655 /* ------------------------------------------------------------ */
860 /** 656 /**
861 * Reconstructs the URL the client used to make the request. The returned URL contains a protocol, server name, port number, and, but it does not include a 657 * Reconstructs the URL the client used to make the request. The returned URL contains a protocol, server name, port number, and, but it does not include a
883 url.append(port); 679 url.append(port);
884 } 680 }
885 return url; 681 return url;
886 } 682 }
887 683
888 /* ------------------------------------------------------------ */ 684 @Override
889 /*
890 * @see javax.servlet.ServletRequest#getScheme()
891 */
892 public String getScheme() 685 public String getScheme()
893 { 686 {
894 return _scheme; 687 return _scheme;
895 } 688 }
896 689
897 /* ------------------------------------------------------------ */ 690 @Override
898 /*
899 * @see javax.servlet.ServletRequest#getServerName()
900 */
901 public String getServerName() 691 public String getServerName()
902 { 692 {
903 // Return already determined host 693 // Return already determined host
904 if (_serverName != null) 694 if (_serverName != null)
905 return _serverName; 695 return _serverName;
933 } 723 }
934 catch (NumberFormatException e) 724 catch (NumberFormatException e)
935 { 725 {
936 try 726 try
937 { 727 {
938 if (_connection != null) 728 _connection._generator.sendError(HttpStatus.BAD_REQUEST_400,"Bad Host header",null,true);
939 _connection._generator.sendError(HttpStatus.BAD_REQUEST_400,"Bad Host header",null,true);
940 } 729 }
941 catch (IOException e1) 730 catch (IOException e1)
942 { 731 {
943 throw new RuntimeException(e1); 732 throw new RuntimeException(e1);
944 } 733 }
954 743
955 return _serverName; 744 return _serverName;
956 } 745 }
957 746
958 // Return host from connection 747 // Return host from connection
959 if (_connection != null) 748 _serverName = getLocalName();
960 { 749 _port = getLocalPort();
961 _serverName = getLocalName(); 750 if (_serverName != null && !StringUtil.ALL_INTERFACES.equals(_serverName))
962 _port = getLocalPort(); 751 return _serverName;
963 if (_serverName != null && !StringUtil.ALL_INTERFACES.equals(_serverName))
964 return _serverName;
965 }
966 752
967 // Return the local host 753 // Return the local host
968 try 754 try
969 { 755 {
970 _serverName = InetAddress.getLocalHost().getHostAddress(); 756 _serverName = InetAddress.getLocalHost().getHostAddress();
974 LOG.trace("",e); 760 LOG.trace("",e);
975 } 761 }
976 return _serverName; 762 return _serverName;
977 } 763 }
978 764
979 /* ------------------------------------------------------------ */ 765 @Override
980 /*
981 * @see javax.servlet.ServletRequest#getServerPort()
982 */
983 public int getServerPort() 766 public int getServerPort()
984 { 767 {
985 if (_port <= 0) 768 if (_port <= 0)
986 { 769 {
987 if (_serverName == null) 770 if (_serverName == null)
990 if (_port <= 0) 773 if (_port <= 0)
991 { 774 {
992 if (_serverName != null && _uri != null) 775 if (_serverName != null && _uri != null)
993 _port = _uri.getPort(); 776 _port = _uri.getPort();
994 else 777 else
995 _port = _endp == null?0:_endp.getLocalPort(); 778 _port = _endp.getLocalPort();
996 } 779 }
997 } 780 }
998 781
999 if (_port <= 0) 782 if (_port <= 0)
1000 { 783 {
1009 public ServletContext getServletContext() 792 public ServletContext getServletContext()
1010 { 793 {
1011 throw new UnsupportedOperationException(); 794 throw new UnsupportedOperationException();
1012 } 795 }
1013 796
1014 /* ------------------------------------------------------------ */ 797 @Override
1015 /*
1016 * @see javax.servlet.http.HttpServletRequest#getServletPath()
1017 */
1018 public String getServletPath() 798 public String getServletPath()
1019 { 799 {
1020 if (_servletPath == null) 800 throw new UnsupportedOperationException();
1021 _servletPath = ""; 801 }
1022 return _servletPath; 802
1023 } 803 @Override
1024
1025 /* ------------------------------------------------------------ */
1026 public ServletResponse getServletResponse()
1027 {
1028 return _connection.getResponse();
1029 }
1030
1031 /* ------------------------------------------------------------ */
1032 /*
1033 * @see javax.servlet.http.HttpServletRequest#getSession()
1034 */
1035 public HttpSession getSession() 804 public HttpSession getSession()
1036 { 805 {
1037 return getSession(true); 806 throw new UnsupportedOperationException();
1038 } 807 }
1039 808
1040 /* ------------------------------------------------------------ */ 809 @Override
1041 /*
1042 * @see javax.servlet.http.HttpServletRequest#getSession(boolean)
1043 */
1044 public HttpSession getSession(boolean create) 810 public HttpSession getSession(boolean create)
1045 { 811 {
1046 throw new UnsupportedOperationException(); 812 throw new UnsupportedOperationException();
1047 } 813 }
1048 814
1057 return _timeStamp; 823 return _timeStamp;
1058 } 824 }
1059 825
1060 /* ------------------------------------------------------------ */ 826 /* ------------------------------------------------------------ */
1061 /** 827 /**
1062 * Get Request TimeStamp
1063 *
1064 * @return The time that the request was received.
1065 */
1066 public Buffer getTimeStampBuffer()
1067 {
1068 if (_timeStampBuffer == null && _timeStamp > 0)
1069 _timeStampBuffer = formatBuffer(_timeStamp);
1070 return _timeStampBuffer;
1071 }
1072
1073 /* ------------------------------------------------------------ */
1074 /**
1075 * @return Returns the uri. 828 * @return Returns the uri.
1076 */ 829 */
1077 public HttpURI getUri() 830 public HttpURI getUri()
1078 { 831 {
1079 return _uri; 832 return _uri;
1080 } 833 }
1081 834
1082 /* ------------------------------------------------------------ */ 835 @Override
1083 /*
1084 * @see javax.servlet.http.HttpServletRequest#getUserPrincipal()
1085 */
1086 public Principal getUserPrincipal() 836 public Principal getUserPrincipal()
1087 { 837 {
1088 return null; 838 return null;
1089 } 839 }
1090 840
1091 /* ------------------------------------------------------------ */
1092 /**
1093 * Get timestamp of the request dispatch
1094 *
1095 * @return timestamp
1096 */
1097 public long getDispatchTime()
1098 {
1099 return _dispatchTime;
1100 }
1101
1102 /* ------------------------------------------------------------ */
1103 public boolean isHandled() 841 public boolean isHandled()
1104 { 842 {
1105 return _handled; 843 return _handled;
1106 } 844 }
1107 845
846 @Override
1108 public boolean isAsyncStarted() 847 public boolean isAsyncStarted()
1109 { 848 {
1110 return false; 849 return false;
1111 } 850 }
1112 851
1113 852 @Override
1114 public boolean isAsyncSupported() 853 public boolean isAsyncSupported()
1115 { 854 {
1116 return false; 855 return false;
1117 } 856 }
1118 857
1119 /* ------------------------------------------------------------ */ 858 @Override
1120 /*
1121 * @see javax.servlet.http.HttpServletRequest#isRequestedSessionIdFromCookie()
1122 */
1123 public boolean isRequestedSessionIdFromCookie() 859 public boolean isRequestedSessionIdFromCookie()
1124 { 860 {
1125 throw new UnsupportedOperationException(); 861 throw new UnsupportedOperationException();
1126 } 862 }
1127 863
1128 /* ------------------------------------------------------------ */ 864 @Override
1129 /*
1130 * @see javax.servlet.http.HttpServletRequest#isRequestedSessionIdFromUrl()
1131 */
1132 public boolean isRequestedSessionIdFromUrl() 865 public boolean isRequestedSessionIdFromUrl()
1133 { 866 {
1134 throw new UnsupportedOperationException(); 867 throw new UnsupportedOperationException();
1135 } 868 }
1136 869
1137 /* ------------------------------------------------------------ */ 870 @Override
1138 /*
1139 * @see javax.servlet.http.HttpServletRequest#isRequestedSessionIdFromURL()
1140 */
1141 public boolean isRequestedSessionIdFromURL() 871 public boolean isRequestedSessionIdFromURL()
1142 { 872 {
1143 throw new UnsupportedOperationException(); 873 throw new UnsupportedOperationException();
1144 } 874 }
1145 875
1146 /* ------------------------------------------------------------ */ 876 @Override
1147 /*
1148 * @see javax.servlet.http.HttpServletRequest#isRequestedSessionIdValid()
1149 */
1150 public boolean isRequestedSessionIdValid() 877 public boolean isRequestedSessionIdValid()
1151 { 878 {
1152 throw new UnsupportedOperationException(); 879 throw new UnsupportedOperationException();
1153 } 880 }
1154 881
1155 /* ------------------------------------------------------------ */ 882 @Override
1156 /*
1157 * @see javax.servlet.ServletRequest#isSecure()
1158 */
1159 public boolean isSecure() 883 public boolean isSecure()
1160 { 884 {
1161 return _connection.getConnector().isConfidential(); 885 return _connection.getConnector().isConfidential();
1162 } 886 }
1163 887
1164 /* ------------------------------------------------------------ */ 888 @Override
1165 /*
1166 * @see javax.servlet.http.HttpServletRequest#isUserInRole(java.lang.String)
1167 */
1168 public boolean isUserInRole(String role) 889 public boolean isUserInRole(String role)
1169 { 890 {
1170 return false; 891 return false;
1171 }
1172
1173 /* ------------------------------------------------------------ */
1174 public HttpSession recoverNewSession(Object key)
1175 {
1176 throw new UnsupportedOperationException();
1177 } 892 }
1178 893
1179 protected void recycle() 894 protected void recycle()
1180 { 895 {
1181 if (_inputState == __READER) 896 if (_inputState == __READER)
1209 _port = 0; 924 _port = 0;
1210 _protocol = HttpVersions.HTTP_1_1; 925 _protocol = HttpVersions.HTTP_1_1;
1211 _queryString = null; 926 _queryString = null;
1212 _requestURI = null; 927 _requestURI = null;
1213 _scheme = URIUtil.HTTP; 928 _scheme = URIUtil.HTTP;
1214 _servletPath = null;
1215 _timeStamp = 0; 929 _timeStamp = 0;
1216 _timeStampBuffer = null;
1217 _uri = null; 930 _uri = null;
1218 if (_baseParameters != null) 931 if (_baseParameters != null)
1219 _baseParameters.clear(); 932 _baseParameters.clear();
1220 _parameters = null; 933 _parameters = null;
1221 _paramsExtracted = false; 934 _paramsExtracted = false;
1222 _inputState = __NONE; 935 _inputState = __NONE;
1223 } 936 }
1224 937
1225 /* ------------------------------------------------------------ */ 938 @Override
1226 /*
1227 * @see javax.servlet.ServletRequest#removeAttribute(java.lang.String)
1228 */
1229 public void removeAttribute(String name) 939 public void removeAttribute(String name)
1230 { 940 {
1231 if (_attributes != null) 941 if (_attributes != null)
1232 _attributes.removeAttribute(name); 942 _attributes.removeAttribute(name);
1233 } 943 }
1239 * #flushResponseBuffer} <p> if the attribute name is "org.eclipse.jetty.io.EndPoint.maxIdleTime", then the value is passed to the associated {@link 949 * #flushResponseBuffer} <p> if the attribute name is "org.eclipse.jetty.io.EndPoint.maxIdleTime", then the value is passed to the associated {@link
1240 * EndPoint#setMaxIdleTime}. 950 * EndPoint#setMaxIdleTime}.
1241 * 951 *
1242 * @see javax.servlet.ServletRequest#setAttribute(java.lang.String, java.lang.Object) 952 * @see javax.servlet.ServletRequest#setAttribute(java.lang.String, java.lang.Object)
1243 */ 953 */
954 @Override
1244 public void setAttribute(String name, Object value) 955 public void setAttribute(String name, Object value)
1245 { 956 {
1246 if (_attributes == null) 957 if (_attributes == null)
1247 _attributes = new AttributesMap(); 958 _attributes = new AttributesMap();
1248 _attributes.setAttribute(name,value); 959 _attributes.setAttribute(name,value);
1249 } 960 }
1250 961
1251 /* ------------------------------------------------------------ */ 962 @Override
1252 /*
1253 * @see javax.servlet.ServletRequest#setCharacterEncoding(java.lang.String)
1254 */
1255 public void setCharacterEncoding(String encoding) throws UnsupportedEncodingException 963 public void setCharacterEncoding(String encoding) throws UnsupportedEncodingException
1256 { 964 {
1257 if (_inputState != __NONE) 965 if (_inputState != __NONE)
1258 return; 966 return;
1259 967
1263 if (!StringUtil.isUTF8(encoding)) 971 if (!StringUtil.isUTF8(encoding))
1264 // noinspection ResultOfMethodCallIgnored 972 // noinspection ResultOfMethodCallIgnored
1265 "".getBytes(encoding); 973 "".getBytes(encoding);
1266 } 974 }
1267 975
1268 /* ------------------------------------------------------------ */
1269 /*
1270 * @see javax.servlet.ServletRequest#setCharacterEncoding(java.lang.String)
1271 */
1272 public void setCharacterEncodingUnchecked(String encoding) 976 public void setCharacterEncodingUnchecked(String encoding)
1273 { 977 {
1274 _characterEncoding = encoding; 978 _characterEncoding = encoding;
1275 } 979 }
1276 980
1277 /* ------------------------------------------------------------ */
1278 // final so we can safely call this from constructor
1279 protected final void setConnection(AbstractHttpConnection connection)
1280 {
1281 _connection = connection;
1282 _endp = connection.getEndPoint();
1283 }
1284
1285 /* ------------------------------------------------------------ */
1286 /*
1287 * @see javax.servlet.ServletRequest#getContentType()
1288 */
1289 public void setContentType(String contentType)
1290 {
1291 _connection._requestFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,contentType);
1292
1293 }
1294
1295 /* ------------------------------------------------------------ */
1296 /**
1297 * Sets the "context path" for this request
1298 *
1299 * @see HttpServletRequest#getContextPath()
1300 */
1301 public void setContextPath(String contextPath) 981 public void setContextPath(String contextPath)
1302 { 982 {
1303 _contextPath = contextPath; 983 _contextPath = contextPath;
1304 } 984 }
1305 985
1306 /* ------------------------------------------------------------ */ 986 /*
1307 /**
1308 * @param cookies
1309 * The cookies to set.
1310 */
1311 public void setCookies(Cookie[] cookies) 987 public void setCookies(Cookie[] cookies)
1312 { 988 {
1313 if (_cookies == null) 989 if (_cookies == null)
1314 _cookies = new CookieCutter(); 990 _cookies = new CookieCutter();
1315 _cookies.setCookies(cookies); 991 _cookies.setCookies(cookies);
1316 } 992 }
1317 993 */
1318 /* ------------------------------------------------------------ */ 994
1319 public void setHandled(boolean h) 995 public void setHandled(boolean h)
1320 { 996 {
1321 _handled = h; 997 _handled = h;
1322 } 998 }
1323 999
1324 /* ------------------------------------------------------------ */
1325 /**
1326 * @param method
1327 * The method to set.
1328 */
1329 public void setMethod(String method) 1000 public void setMethod(String method)
1330 { 1001 {
1331 _method = method; 1002 _method = method;
1332 } 1003 }
1333 1004
1334 /* ------------------------------------------------------------ */ 1005 private void setParameters(MultiMap<String> parameters)
1335 /**
1336 * @param parameters
1337 * The parameters to set.
1338 */
1339 public void setParameters(MultiMap<String> parameters)
1340 { 1006 {
1341 _parameters = (parameters == null)?_baseParameters:parameters; 1007 _parameters = (parameters == null)?_baseParameters:parameters;
1342 if (_paramsExtracted && _parameters == null) 1008 if (_paramsExtracted && _parameters == null)
1343 throw new IllegalStateException(); 1009 throw new IllegalStateException();
1344 } 1010 }
1345 1011
1346 /* ------------------------------------------------------------ */
1347 /**
1348 * @param pathInfo
1349 * The pathInfo to set.
1350 */
1351 public void setPathInfo(String pathInfo) 1012 public void setPathInfo(String pathInfo)
1352 { 1013 {
1353 _pathInfo = pathInfo; 1014 _pathInfo = pathInfo;
1354 } 1015 }
1355 1016
1356 /* ------------------------------------------------------------ */
1357 /**
1358 * @param protocol
1359 * The protocol to set.
1360 */
1361 public void setProtocol(String protocol) 1017 public void setProtocol(String protocol)
1362 { 1018 {
1363 _protocol = protocol; 1019 _protocol = protocol;
1364 } 1020 }
1365 1021
1366 /* ------------------------------------------------------------ */
1367 /**
1368 * @param queryString
1369 * The queryString to set.
1370 */
1371 public void setQueryString(String queryString)
1372 {
1373 _queryString = queryString;
1374 }
1375
1376 /* ------------------------------------------------------------ */
1377 /**
1378 * @param addr
1379 * The address to set.
1380 */
1381 public void setRemoteAddr(String addr)
1382 {
1383 _remoteAddr = addr;
1384 }
1385
1386 /* ------------------------------------------------------------ */
1387 /**
1388 * @param host
1389 * The host to set.
1390 */
1391 public void setRemoteHost(String host)
1392 {
1393 _remoteHost = host;
1394 }
1395
1396 /* ------------------------------------------------------------ */
1397 /**
1398 * @param requestURI
1399 * The requestURI to set.
1400 */
1401 public void setRequestURI(String requestURI) 1022 public void setRequestURI(String requestURI)
1402 { 1023 {
1403 _requestURI = requestURI; 1024 _requestURI = requestURI;
1404 } 1025 }
1405 1026
1406 /* ------------------------------------------------------------ */
1407 /**
1408 * @param scheme
1409 * The scheme to set.
1410 */
1411 public void setScheme(String scheme) 1027 public void setScheme(String scheme)
1412 { 1028 {
1413 _scheme = scheme; 1029 _scheme = scheme;
1414 } 1030 }
1415 1031
1416 /* ------------------------------------------------------------ */
1417 /**
1418 * @param host
1419 * The host to set.
1420 */
1421 public void setServerName(String host)
1422 {
1423 _serverName = host;
1424 }
1425
1426 /* ------------------------------------------------------------ */
1427 /**
1428 * @param port
1429 * The port to set.
1430 */
1431 public void setServerPort(int port)
1432 {
1433 _port = port;
1434 }
1435
1436 /* ------------------------------------------------------------ */
1437 /**
1438 * @param servletPath
1439 * The servletPath to set.
1440 */
1441 public void setServletPath(String servletPath)
1442 {
1443 _servletPath = servletPath;
1444 }
1445
1446 /* ------------------------------------------------------------ */
1447 public void setTimeStamp(long ts) 1032 public void setTimeStamp(long ts)
1448 { 1033 {
1449 _timeStamp = ts; 1034 _timeStamp = ts;
1450 } 1035 }
1451 1036
1452 /* ------------------------------------------------------------ */
1453 /**
1454 * @param uri
1455 * The uri to set.
1456 */
1457 public void setUri(HttpURI uri) 1037 public void setUri(HttpURI uri)
1458 { 1038 {
1459 _uri = uri; 1039 _uri = uri;
1460 } 1040 }
1461 1041
1462 /* ------------------------------------------------------------ */ 1042 @Override
1463 /**
1464 * Set timetstamp of request dispatch
1465 *
1466 * @param value
1467 * timestamp
1468 */
1469 public void setDispatchTime(long value)
1470 {
1471 _dispatchTime = value;
1472 }
1473
1474 /* ------------------------------------------------------------ */
1475 public AsyncContext startAsync() throws IllegalStateException 1043 public AsyncContext startAsync() throws IllegalStateException
1476 { 1044 {
1477 throw new UnsupportedOperationException(); 1045 throw new UnsupportedOperationException();
1478 } 1046 }
1479 1047
1480 /* ------------------------------------------------------------ */ 1048 @Override
1481 public AsyncContext startAsync(ServletRequest servletRequest, ServletResponse servletResponse) throws IllegalStateException 1049 public AsyncContext startAsync(ServletRequest servletRequest, ServletResponse servletResponse) throws IllegalStateException
1482 { 1050 {
1483 throw new UnsupportedOperationException(); 1051 throw new UnsupportedOperationException();
1484 } 1052 }
1485 1053
1486 /* ------------------------------------------------------------ */
1487 @Override 1054 @Override
1488 public String toString() 1055 public String toString()
1489 { 1056 {
1490 return (_handled?"[":"(") + getMethod() + " " + _uri + (_handled?"]@":")@") + hashCode() + " " + super.toString(); 1057 return (_handled?"[":"(") + getMethod() + " " + _uri + (_handled?"]@":")@") + hashCode() + " " + super.toString();
1491 } 1058 }
1492 1059
1493 /* ------------------------------------------------------------ */ 1060 @Override
1494 public boolean authenticate(HttpServletResponse response) throws IOException, ServletException 1061 public boolean authenticate(HttpServletResponse response) throws IOException, ServletException
1495 { 1062 {
1496 throw new UnsupportedOperationException(); 1063 throw new UnsupportedOperationException();
1497 } 1064 }
1498 1065
1499 /* ------------------------------------------------------------ */ 1066 @Override
1500 public Part getPart(String name) throws IOException, ServletException 1067 public Part getPart(String name) throws IOException, ServletException
1501 { 1068 {
1502 throw new UnsupportedOperationException(); 1069 throw new UnsupportedOperationException();
1503 } 1070 }
1504 1071
1505 /* ------------------------------------------------------------ */ 1072 @Override
1506 public Collection<Part> getParts() throws IOException, ServletException 1073 public Collection<Part> getParts() throws IOException, ServletException
1507 { 1074 {
1508 throw new UnsupportedOperationException(); 1075 throw new UnsupportedOperationException();
1509 } 1076 }
1510 1077
1511 /* ------------------------------------------------------------ */ 1078 @Override
1512 public void login(String username, String password) throws ServletException 1079 public void login(String username, String password) throws ServletException
1513 { 1080 {
1514 throw new UnsupportedOperationException(); 1081 throw new UnsupportedOperationException();
1515 } 1082 }
1516 1083
1517 /* ------------------------------------------------------------ */ 1084 @Override
1518 public void logout() throws ServletException 1085 public void logout() throws ServletException
1519 { 1086 {
1520 throw new UnsupportedOperationException(); 1087 throw new UnsupportedOperationException();
1521 } 1088 }
1522
1523 /* ------------------------------------------------------------ */
1524 /**
1525 * Merge in a new query string. The query string is merged with the existing parameters and {@link #setParameters(MultiMap)} and
1526 * {@link #setQueryString(String)} are called with the result. The merge is according to the rules of the servlet dispatch forward method.
1527 *
1528 * @param query
1529 * The query string to merge into the request.
1530 */
1531 public void mergeQueryString(String query)
1532 {
1533 // extract parameters from dispatch query
1534 MultiMap<String> parameters = new MultiMap<String>();
1535 UrlEncoded.decodeTo(query,parameters, StringUtil.__UTF8); //have to assume UTF-8 because we can't know otherwise
1536
1537 boolean merge_old_query = false;
1538
1539 // Have we evaluated parameters
1540 if (!_paramsExtracted)
1541 extractParameters();
1542
1543 // Are there any existing parameters?
1544 if (_parameters != null && _parameters.size() > 0)
1545 {
1546 // Merge parameters; new parameters of the same name take precedence.
1547 Iterator<Entry<String, Object>> iter = _parameters.entrySet().iterator();
1548 while (iter.hasNext())
1549 {
1550 Map.Entry<String, Object> entry = iter.next();
1551 String name = entry.getKey();
1552
1553 // If the names match, we will need to remake the query string
1554 if (parameters.containsKey(name))
1555 merge_old_query = true;
1556
1557 // Add the old values to the new parameter map
1558 Object values = entry.getValue();
1559 for (int i = 0; i < LazyList.size(values); i++)
1560 parameters.add(name,LazyList.get(values,i));
1561 }
1562 }
1563
1564 if (_queryString != null && _queryString.length() > 0)
1565 {
1566 if (merge_old_query)
1567 {
1568 StringBuilder overridden_query_string = new StringBuilder();
1569 MultiMap<String> overridden_old_query = new MultiMap<String>();
1570 UrlEncoded.decodeTo(_queryString,overridden_old_query,null);//decode using any queryencoding set for the request
1571
1572
1573 MultiMap<String> overridden_new_query = new MultiMap<String>();
1574 UrlEncoded.decodeTo(query,overridden_new_query,StringUtil.__UTF8); //have to assume utf8 as we cannot know otherwise
1575
1576 Iterator<Entry<String, Object>> iter = overridden_old_query.entrySet().iterator();
1577 while (iter.hasNext())
1578 {
1579 Map.Entry<String, Object> entry = iter.next();
1580 String name = entry.getKey();
1581 if (!overridden_new_query.containsKey(name))
1582 {
1583 Object values = entry.getValue();
1584 for (int i = 0; i < LazyList.size(values); i++)
1585 {
1586 overridden_query_string.append("&").append(name).append("=").append((Object)LazyList.get(values,i));
1587 }
1588 }
1589 }
1590
1591 query = query + overridden_query_string;
1592 }
1593 else
1594 {
1595 query = query + "&" + _queryString;
1596 }
1597 }
1598
1599 setParameters(parameters);
1600 setQueryString(query);
1601 }
1602
1603
1604 private static Buffer _buffer;
1605 private static String _last;
1606 private static final DateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss 'GMT'", Locale.US);
1607 static {
1608 dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
1609 }
1610
1611 private static Buffer formatBuffer(long date) {
1612 synchronized(dateFormat) {
1613 String d = dateFormat.format(date);
1614 if (d==_last)
1615 return _buffer;
1616 _last=d;
1617 _buffer=new ByteArrayBuffer(d);
1618 return _buffer;
1619 }
1620 }
1621 1089
1622 } 1090 }