org.eclipse.jetty.http_8.1.3.v20120522

16:45:22.931 INFO  jd.cli.Main - Decompiling org.eclipse.jetty.http_8.1.3.v20120522.jar
package org.eclipse.jetty.http.ssl;

/**
 * @deprecated
 */
public class SslContextFactory
  extends org.eclipse.jetty.util.ssl.SslContextFactory
{
  public SslContextFactory() {}
  
  public SslContextFactory(boolean trustAll)
  {
    super(trustAll);
  }
  
  public SslContextFactory(String keyStorePath)
  {
    super(keyStorePath);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jetty.http.ssl.SslContextFactory
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jetty.http;

import java.io.IOException;
import org.eclipse.jetty.io.Buffer;
import org.eclipse.jetty.io.BufferCache.CachedBuffer;
import org.eclipse.jetty.io.BufferUtil;

public final class HttpFields$Field
{
  private Buffer _name;
  private Buffer _value;
  private Field _next;
  
  private HttpFields$Field(Buffer name, Buffer value)
  {
    _name = name;
    _value = value;
    _next = null;
  }
  
  public void putTo(Buffer buffer)
    throws IOException
  {
    int o = (_name instanceof BufferCache.CachedBuffer) ? ((BufferCache.CachedBuffer)_name).getOrdinal() : -1;
    if (o >= 0)
    {
      buffer.put(_name);
    }
    else
    {
      int s = _name.getIndex();
      int e = _name.putIndex();
      while (s < e)
      {
        byte b = _name.peek(s++);
        switch (b)
        {
        case 10: 
        case 13: 
        case 58: 
          break;
        default: 
          buffer.put(b);
        }
      }
    }
    buffer.put((byte)58);
    buffer.put((byte)32);
    
    o = (_value instanceof BufferCache.CachedBuffer) ? ((BufferCache.CachedBuffer)_value).getOrdinal() : -1;
    if (o >= 0)
    {
      buffer.put(_value);
    }
    else
    {
      int s = _value.getIndex();
      int e = _value.putIndex();
      while (s < e)
      {
        byte b = _value.peek(s++);
        switch (b)
        {
        case 10: 
        case 13: 
          break;
        default: 
          buffer.put(b);
        }
      }
    }
    BufferUtil.putCRLF(buffer);
  }
  
  public String getName()
  {
    return BufferUtil.to8859_1_String(_name);
  }
  
  Buffer getNameBuffer()
  {
    return _name;
  }
  
  public int getNameOrdinal()
  {
    return HttpHeaders.CACHE.getOrdinal(_name);
  }
  
  public String getValue()
  {
    return BufferUtil.to8859_1_String(_value);
  }
  
  public Buffer getValueBuffer()
  {
    return _value;
  }
  
  public int getValueOrdinal()
  {
    return HttpHeaderValues.CACHE.getOrdinal(_value);
  }
  
  public int getIntValue()
  {
    return (int)getLongValue();
  }
  
  public long getLongValue()
  {
    return BufferUtil.toLong(_value);
  }
  
  public String toString()
  {
    return "[" + getName() + "=" + _value + (_next == null ? "" : "->") + "]";
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jetty.http.HttpFields.Field
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jetty.http.gzip;

import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.zip.DeflaterOutputStream;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.util.ByteArrayOutputStream2;

public abstract class AbstractCompressedStream
  extends ServletOutputStream
{
  private final String _encoding;
  protected HttpServletRequest _request;
  protected HttpServletResponse _response;
  protected OutputStream _out;
  protected ByteArrayOutputStream2 _bOut;
  protected DeflaterOutputStream _compressedOutputStream;
  protected boolean _closed;
  protected int _bufferSize;
  protected int _minCompressSize;
  protected long _contentLength;
  protected boolean _doNotCompress;
  
  public AbstractCompressedStream(String encoding, HttpServletRequest request, HttpServletResponse response, long contentLength, int bufferSize, int minCompressSize)
    throws IOException
  {
    _encoding = encoding;
    _request = request;
    _response = response;
    _contentLength = contentLength;
    _bufferSize = bufferSize;
    _minCompressSize = minCompressSize;
    if (minCompressSize == 0) {
      doCompress();
    }
  }
  
  public void resetBuffer()
  {
    if (_response.isCommitted()) {
      throw new IllegalStateException("Committed");
    }
    _closed = false;
    _out = null;
    _bOut = null;
    if (_compressedOutputStream != null) {
      _response.setHeader("Content-Encoding", null);
    }
    _compressedOutputStream = null;
    _doNotCompress = false;
  }
  
  public void setContentLength(long length)
  {
    _contentLength = length;
    if ((_doNotCompress) && (length >= 0L)) {
      if (_contentLength < 2147483647L) {
        _response.setContentLength((int)_contentLength);
      } else {
        _response.setHeader("Content-Length", Long.toString(_contentLength));
      }
    }
  }
  
  public void flush()
    throws IOException
  {
    if ((_out == null) || (_bOut != null)) {
      if ((_contentLength > 0L) && (_contentLength < _minCompressSize)) {
        doNotCompress();
      } else {
        doCompress();
      }
    }
    _out.flush();
  }
  
  public void close()
    throws IOException
  {
    if (_closed) {
      return;
    }
    if (_request.getAttribute("javax.servlet.include.request_uri") != null)
    {
      flush();
    }
    else
    {
      if (_bOut != null)
      {
        if (_contentLength < 0L) {
          _contentLength = _bOut.getCount();
        }
        if (_contentLength < _minCompressSize) {
          doNotCompress();
        } else {
          doCompress();
        }
      }
      else if (_out == null)
      {
        doNotCompress();
      }
      if (_compressedOutputStream != null) {
        _compressedOutputStream.close();
      } else {
        _out.close();
      }
      _closed = true;
    }
  }
  
  public void finish()
    throws IOException
  {
    if (!_closed)
    {
      if ((_out == null) || (_bOut != null)) {
        if ((_contentLength > 0L) && (_contentLength < _minCompressSize)) {
          doNotCompress();
        } else {
          doCompress();
        }
      }
      if ((_compressedOutputStream != null) && (!_closed))
      {
        _closed = true;
        _compressedOutputStream.close();
      }
    }
  }
  
  public void write(int b)
    throws IOException
  {
    checkOut(1);
    _out.write(b);
  }
  
  public void write(byte[] b)
    throws IOException
  {
    checkOut(b.length);
    _out.write(b);
  }
  
  public void write(byte[] b, int off, int len)
    throws IOException
  {
    checkOut(len);
    _out.write(b, off, len);
  }
  
  public void doCompress()
    throws IOException
  {
    if (_compressedOutputStream == null)
    {
      if (_response.isCommitted()) {
        throw new IllegalStateException();
      }
      setHeader("Content-Encoding", _encoding);
      if (_response.containsHeader("Content-Encoding"))
      {
        _out = (_compressedOutputStream = createStream());
        if (_bOut != null)
        {
          _out.write(_bOut.getBuf(), 0, _bOut.getCount());
          _bOut = null;
        }
      }
      else
      {
        doNotCompress();
      }
    }
  }
  
  public void doNotCompress()
    throws IOException
  {
    if (_compressedOutputStream != null) {
      throw new IllegalStateException();
    }
    if ((_out == null) || (_bOut != null))
    {
      _doNotCompress = true;
      
      _out = _response.getOutputStream();
      setContentLength(_contentLength);
      if (_bOut != null) {
        _out.write(_bOut.getBuf(), 0, _bOut.getCount());
      }
      _bOut = null;
    }
  }
  
  private void checkOut(int length)
    throws IOException
  {
    if (_closed) {
      throw new IOException("CLOSED");
    }
    if (_out == null)
    {
      if ((_response.isCommitted()) || ((_contentLength >= 0L) && (_contentLength < _minCompressSize))) {
        doNotCompress();
      } else if (length > _minCompressSize) {
        doCompress();
      } else {
        _out = (_bOut = new ByteArrayOutputStream2(_bufferSize));
      }
    }
    else if (_bOut != null) {
      if ((_response.isCommitted()) || ((_contentLength >= 0L) && (_contentLength < _minCompressSize))) {
        doNotCompress();
      } else if (length >= _bOut.getBuf().length - _bOut.getCount()) {
        doCompress();
      }
    }
  }
  
  public OutputStream getOutputStream()
  {
    return _out;
  }
  
  public boolean isClosed()
  {
    return _closed;
  }
  
  protected PrintWriter newWriter(OutputStream out, String encoding)
    throws UnsupportedEncodingException
  {
    return encoding == null ? new PrintWriter(out) : new PrintWriter(new OutputStreamWriter(out, encoding));
  }
  
  protected void setHeader(String name, String value)
  {
    _response.setHeader(name, value);
  }
  
  protected abstract DeflaterOutputStream createStream()
    throws IOException;
}

/* Location:
 * Qualified Name:     org.eclipse.jetty.http.gzip.AbstractCompressedStream
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jetty.http.gzip;

import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.Set;
import javax.servlet.ServletOutputStream;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;
import org.eclipse.jetty.util.StringUtil;

public abstract class CompressedResponseWrapper
  extends HttpServletResponseWrapper
{
  public static final int DEFAULT_BUFFER_SIZE = 8192;
  public static final int DEFAULT_MIN_COMPRESS_SIZE = 256;
  private Set<String> _mimeTypes;
  private int _bufferSize = 8192;
  private int _minCompressSize = 256;
  protected HttpServletRequest _request;
  private PrintWriter _writer;
  private AbstractCompressedStream _compressedStream;
  private long _contentLength = -1L;
  private boolean _noCompression;
  
  public CompressedResponseWrapper(HttpServletRequest request, HttpServletResponse response)
  {
    super(response);
    _request = request;
  }
  
  public void setMimeTypes(Set<String> mimeTypes)
  {
    _mimeTypes = mimeTypes;
  }
  
  public void setBufferSize(int bufferSize)
  {
    _bufferSize = bufferSize;
  }
  
  public void setMinCompressSize(int minCompressSize)
  {
    _minCompressSize = minCompressSize;
  }
  
  public void setContentType(String ct)
  {
    super.setContentType(ct);
    if (ct != null)
    {
      int colon = ct.indexOf(";");
      if (colon > 0) {
        ct = ct.substring(0, colon);
      }
    }
    if (((_compressedStream == null) || (_compressedStream.getOutputStream() == null)) && (((_mimeTypes == null) && (ct != null) && (ct.contains("gzip"))) || ((_mimeTypes != null) && ((ct == null) || (!_mimeTypes.contains(StringUtil.asciiToLowerCase(ct))))))) {
      noCompression();
    }
  }
  
  public void setStatus(int sc, String sm)
  {
    super.setStatus(sc, sm);
    if ((sc < 200) || (sc == 204) || (sc == 205) || (sc >= 300)) {
      noCompression();
    }
  }
  
  public void setStatus(int sc)
  {
    super.setStatus(sc);
    if ((sc < 200) || (sc == 204) || (sc == 205) || (sc >= 300)) {
      noCompression();
    }
  }
  
  public void setContentLength(int length)
  {
    setContentLength(length);
  }
  
  protected void setContentLength(long length)
  {
    _contentLength = length;
    if (_compressedStream != null)
    {
      _compressedStream.setContentLength(length);
    }
    else if ((_noCompression) && (_contentLength >= 0L))
    {
      HttpServletResponse response = (HttpServletResponse)getResponse();
      if (_contentLength < 2147483647L) {
        response.setContentLength((int)_contentLength);
      } else {
        response.setHeader("Content-Length", Long.toString(_contentLength));
      }
    }
  }
  
  public void addHeader(String name, String value)
  {
    if ("content-length".equalsIgnoreCase(name))
    {
      _contentLength = Long.parseLong(value);
      if (_compressedStream != null) {
        _compressedStream.setContentLength(_contentLength);
      }
    }
    else if ("content-type".equalsIgnoreCase(name))
    {
      setContentType(value);
    }
    else if ("content-encoding".equalsIgnoreCase(name))
    {
      super.addHeader(name, value);
      if (!isCommitted()) {
        noCompression();
      }
    }
    else
    {
      super.addHeader(name, value);
    }
  }
  
  public void flushBuffer()
    throws IOException
  {
    if (_writer != null) {
      _writer.flush();
    }
    if (_compressedStream != null) {
      _compressedStream.finish();
    } else {
      getResponse().flushBuffer();
    }
  }
  
  public void reset()
  {
    super.reset();
    if (_compressedStream != null) {
      _compressedStream.resetBuffer();
    }
    _writer = null;
    _compressedStream = null;
    _noCompression = false;
    _contentLength = -1L;
  }
  
  public void resetBuffer()
  {
    super.resetBuffer();
    if (_compressedStream != null) {
      _compressedStream.resetBuffer();
    }
    _writer = null;
    _compressedStream = null;
  }
  
  public void sendError(int sc, String msg)
    throws IOException
  {
    resetBuffer();
    super.sendError(sc, msg);
  }
  
  public void sendError(int sc)
    throws IOException
  {
    resetBuffer();
    super.sendError(sc);
  }
  
  public void sendRedirect(String location)
    throws IOException
  {
    resetBuffer();
    super.sendRedirect(location);
  }
  
  public void noCompression()
  {
    _noCompression = true;
    if (_compressedStream != null) {
      try
      {
        _compressedStream.doNotCompress();
      }
      catch (IOException e)
      {
        throw new IllegalStateException(e);
      }
    }
  }
  
  public void finish()
    throws IOException
  {
    if ((_writer != null) && (!_compressedStream.isClosed())) {
      _writer.flush();
    }
    if (_compressedStream != null) {
      _compressedStream.finish();
    }
  }
  
  public void setHeader(String name, String value)
  {
    if ("content-length".equalsIgnoreCase(name))
    {
      setContentLength(Long.parseLong(value));
    }
    else if ("content-type".equalsIgnoreCase(name))
    {
      setContentType(value);
    }
    else if ("content-encoding".equalsIgnoreCase(name))
    {
      super.setHeader(name, value);
      if (!isCommitted()) {
        noCompression();
      }
    }
    else
    {
      super.setHeader(name, value);
    }
  }
  
  public ServletOutputStream getOutputStream()
    throws IOException
  {
    if (_compressedStream == null)
    {
      if ((getResponse().isCommitted()) || (_noCompression))
      {
        setContentLength(_contentLength);
        return getResponse().getOutputStream();
      }
      _compressedStream = newCompressedStream(_request, (HttpServletResponse)getResponse(), _contentLength, _bufferSize, _minCompressSize);
    }
    else if (_writer != null)
    {
      throw new IllegalStateException("getWriter() called");
    }
    return _compressedStream;
  }
  
  public PrintWriter getWriter()
    throws IOException
  {
    if (_writer == null)
    {
      if (_compressedStream != null) {
        throw new IllegalStateException("getOutputStream() called");
      }
      if ((getResponse().isCommitted()) || (_noCompression))
      {
        setContentLength(_contentLength);
        return getResponse().getWriter();
      }
      _compressedStream = newCompressedStream(_request, (HttpServletResponse)getResponse(), _contentLength, _bufferSize, _minCompressSize);
      _writer = newWriter(_compressedStream, getCharacterEncoding());
    }
    return _writer;
  }
  
  public void setIntHeader(String name, int value)
  {
    if ("content-length".equalsIgnoreCase(name))
    {
      _contentLength = value;
      if (_compressedStream != null) {
        _compressedStream.setContentLength(_contentLength);
      }
    }
    else
    {
      super.setIntHeader(name, value);
    }
  }
  
  protected PrintWriter newWriter(OutputStream out, String encoding)
    throws UnsupportedEncodingException
  {
    return encoding == null ? new PrintWriter(out) : new PrintWriter(new OutputStreamWriter(out, encoding));
  }
  
  protected abstract AbstractCompressedStream newCompressedStream(HttpServletRequest paramHttpServletRequest, HttpServletResponse paramHttpServletResponse, long paramLong, int paramInt1, int paramInt2)
    throws IOException;
}

/* Location:
 * Qualified Name:     org.eclipse.jetty.http.gzip.CompressedResponseWrapper
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jetty.http;

import org.eclipse.jetty.io.Buffer;
import org.eclipse.jetty.io.BufferCache;

public class HttpMethods
{
  public static final String GET = "GET";
  public static final String POST = "POST";
  public static final String HEAD = "HEAD";
  public static final String PUT = "PUT";
  public static final String OPTIONS = "OPTIONS";
  public static final String DELETE = "DELETE";
  public static final String TRACE = "TRACE";
  public static final String CONNECT = "CONNECT";
  public static final String MOVE = "MOVE";
  public static final int GET_ORDINAL = 1;
  public static final int POST_ORDINAL = 2;
  public static final int HEAD_ORDINAL = 3;
  public static final int PUT_ORDINAL = 4;
  public static final int OPTIONS_ORDINAL = 5;
  public static final int DELETE_ORDINAL = 6;
  public static final int TRACE_ORDINAL = 7;
  public static final int CONNECT_ORDINAL = 8;
  public static final int MOVE_ORDINAL = 9;
  public static final BufferCache CACHE = new BufferCache();
  public static final Buffer GET_BUFFER = CACHE.add("GET", 1);
  public static final Buffer POST_BUFFER = CACHE.add("POST", 2);
  public static final Buffer HEAD_BUFFER = CACHE.add("HEAD", 3);
  public static final Buffer PUT_BUFFER = CACHE.add("PUT", 4);
  public static final Buffer OPTIONS_BUFFER = CACHE.add("OPTIONS", 5);
  public static final Buffer DELETE_BUFFER = CACHE.add("DELETE", 6);
  public static final Buffer TRACE_BUFFER = CACHE.add("TRACE", 7);
  public static final Buffer CONNECT_BUFFER = CACHE.add("CONNECT", 8);
  public static final Buffer MOVE_BUFFER = CACHE.add("MOVE", 9);
}

/* Location:
 * Qualified Name:     org.eclipse.jetty.http.HttpMethods
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jetty.http;

public abstract interface HttpTokens
{
  public static final byte COLON = 58;
  public static final byte SPACE = 32;
  public static final byte CARRIAGE_RETURN = 13;
  public static final byte LINE_FEED = 10;
  public static final byte[] CRLF = { 13, 10 };
  public static final byte SEMI_COLON = 59;
  public static final byte TAB = 9;
  public static final int SELF_DEFINING_CONTENT = -4;
  public static final int UNKNOWN_CONTENT = -3;
  public static final int CHUNKED_CONTENT = -2;
  public static final int EOF_CONTENT = -1;
  public static final int NO_CONTENT = 0;
}

/* Location:
 * Qualified Name:     org.eclipse.jetty.http.HttpTokens
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jetty.http;

public class HttpCookie
{
  private final String _name;
  private final String _value;
  private final String _comment;
  private final String _domain;
  private final int _maxAge;
  private final String _path;
  private final boolean _secure;
  private final int _version;
  private final boolean _httpOnly;
  
  public HttpCookie(String name, String value)
  {
    _name = name;
    _value = value;
    _comment = null;
    _domain = null;
    _httpOnly = false;
    _maxAge = -1;
    _path = null;
    _secure = false;
    _version = 0;
  }
  
  public HttpCookie(String name, String value, String domain, String path)
  {
    _name = name;
    _value = value;
    _comment = null;
    _domain = domain;
    _httpOnly = false;
    _maxAge = -1;
    _path = path;
    _secure = false;
    _version = 0;
  }
  
  public HttpCookie(String name, String value, int maxAge)
  {
    _name = name;
    _value = value;
    _comment = null;
    _domain = null;
    _httpOnly = false;
    _maxAge = maxAge;
    _path = null;
    _secure = false;
    _version = 0;
  }
  
  public HttpCookie(String name, String value, String domain, String path, int maxAge, boolean httpOnly, boolean secure)
  {
    _comment = null;
    _domain = domain;
    _httpOnly = httpOnly;
    _maxAge = maxAge;
    _name = name;
    _path = path;
    _secure = secure;
    _value = value;
    _version = 0;
  }
  
  public HttpCookie(String name, String value, String domain, String path, int maxAge, boolean httpOnly, boolean secure, String comment, int version)
  {
    _comment = comment;
    _domain = domain;
    _httpOnly = httpOnly;
    _maxAge = maxAge;
    _name = name;
    _path = path;
    _secure = secure;
    _value = value;
    _version = version;
  }
  
  public String getName()
  {
    return _name;
  }
  
  public String getValue()
  {
    return _value;
  }
  
  public String getComment()
  {
    return _comment;
  }
  
  public String getDomain()
  {
    return _domain;
  }
  
  public int getMaxAge()
  {
    return _maxAge;
  }
  
  public String getPath()
  {
    return _path;
  }
  
  public boolean isSecure()
  {
    return _secure;
  }
  
  public int getVersion()
  {
    return _version;
  }
  
  public boolean isHttpOnly()
  {
    return _httpOnly;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jetty.http.HttpCookie
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jetty.http;

import java.io.IOException;
import java.io.InputStream;
import org.eclipse.jetty.io.Buffer;
import org.eclipse.jetty.io.ByteArrayBuffer;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.resource.Resource;

public class HttpContent$ResourceAsHttpContent
  implements HttpContent
{
  private static final Logger LOG = Log.getLogger(ResourceAsHttpContent.class);
  final Resource _resource;
  final Buffer _mimeType;
  final int _maxBuffer;
  
  public HttpContent$ResourceAsHttpContent(Resource resource, Buffer mimeType)
  {
    _resource = resource;
    _mimeType = mimeType;
    _maxBuffer = -1;
  }
  
  public HttpContent$ResourceAsHttpContent(Resource resource, Buffer mimeType, int maxBuffer)
  {
    _resource = resource;
    _mimeType = mimeType;
    _maxBuffer = maxBuffer;
  }
  
  public Buffer getContentType()
  {
    return _mimeType;
  }
  
  public Buffer getLastModified()
  {
    return null;
  }
  
  public Buffer getDirectBuffer()
  {
    return null;
  }
  
  public Buffer getIndirectBuffer()
  {
    InputStream inputStream = null;
    try
    {
      if ((_resource.length() <= 0L) || (_maxBuffer < _resource.length())) {
        return null;
      }
      ByteArrayBuffer buffer = new ByteArrayBuffer((int)_resource.length());
      inputStream = _resource.getInputStream();
      buffer.readFrom(inputStream, (int)_resource.length());
      return buffer;
    }
    catch (IOException e)
    {
      throw new RuntimeException(e);
    }
    finally
    {
      if (inputStream != null) {
        try
        {
          inputStream.close();
        }
        catch (IOException e)
        {
          LOG.warn("Couldn't close inputStream. Possible file handle leak", e);
        }
      }
    }
  }
  
  public long getContentLength()
  {
    return _resource.length();
  }
  
  public InputStream getInputStream()
    throws IOException
  {
    return _resource.getInputStream();
  }
  
  public Resource getResource()
  {
    return _resource;
  }
  
  public void release()
  {
    _resource.release();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jetty.http.HttpContent.ResourceAsHttpContent
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jetty.http;

import java.util.Enumeration;

class HttpFields$3
  implements Enumeration<String>
{
  HttpFields$3(HttpFields paramHttpFields, Enumeration paramEnumeration) {}
  
  public String nextElement()
  {
    return val$buffers.nextElement().toString();
  }
  
  public boolean hasMoreElements()
  {
    return val$buffers.hasMoreElements();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jetty.http.HttpFields.3
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jetty.http;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.Enumeration;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.NoSuchElementException;
import java.util.StringTokenizer;
import java.util.TimeZone;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import org.eclipse.jetty.io.Buffer;
import org.eclipse.jetty.io.BufferCache.CachedBuffer;
import org.eclipse.jetty.io.BufferDateCache;
import org.eclipse.jetty.io.BufferUtil;
import org.eclipse.jetty.io.ByteArrayBuffer;
import org.eclipse.jetty.util.LazyList;
import org.eclipse.jetty.util.QuotedStringTokenizer;
import org.eclipse.jetty.util.StringMap;
import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;

public class HttpFields
{
  private static final Logger LOG = Log.getLogger(HttpFields.class);
  public static final String __COOKIE_DELIM = "\"\\\n\r\t\f\b%+ ;=";
  public static final TimeZone __GMT = TimeZone.getTimeZone("GMT");
  public static final BufferDateCache __dateCache = new BufferDateCache("EEE, dd MMM yyyy HH:mm:ss 'GMT'", Locale.US);
  public static final String __separators = ", \t";
  private static final String[] DAYS;
  private static final String[] MONTHS;
  private static final ThreadLocal<DateGenerator> __dateGenerator;
  private static final String[] __dateReceiveFmt;
  private static final ThreadLocal<DateParser> __dateParser;
  public static final String __01Jan1970;
  public static final Buffer __01Jan1970_BUFFER;
  public static final String __01Jan1970_COOKIE;
  
  private static class DateGenerator
  {
    private final StringBuilder buf = new StringBuilder(32);
    private final GregorianCalendar gc = new GregorianCalendar(HttpFields.__GMT);
    
    public String formatDate(long date)
    {
      buf.setLength(0);
      gc.setTimeInMillis(date);
      
      int day_of_week = gc.get(7);
      int day_of_month = gc.get(5);
      int month = gc.get(2);
      int year = gc.get(1);
      int century = year / 100;
      year %= 100;
      
      int hours = gc.get(11);
      int minutes = gc.get(12);
      int seconds = gc.get(13);
      
      buf.append(HttpFields.DAYS[day_of_week]);
      buf.append(',');
      buf.append(' ');
      StringUtil.append2digits(buf, day_of_month);
      
      buf.append(' ');
      buf.append(HttpFields.MONTHS[month]);
      buf.append(' ');
      StringUtil.append2digits(buf, century);
      StringUtil.append2digits(buf, year);
      
      buf.append(' ');
      StringUtil.append2digits(buf, hours);
      buf.append(':');
      StringUtil.append2digits(buf, minutes);
      buf.append(':');
      StringUtil.append2digits(buf, seconds);
      buf.append(" GMT");
      return buf.toString();
    }
    
    public void formatCookieDate(StringBuilder buf, long date)
    {
      gc.setTimeInMillis(date);
      
      int day_of_week = gc.get(7);
      int day_of_month = gc.get(5);
      int month = gc.get(2);
      int year = gc.get(1);
      year %= 10000;
      
      int epoch = (int)(date / 1000L % 86400L);
      int seconds = epoch % 60;
      epoch /= 60;
      int minutes = epoch % 60;
      int hours = epoch / 60;
      
      buf.append(HttpFields.DAYS[day_of_week]);
      buf.append(',');
      buf.append(' ');
      StringUtil.append2digits(buf, day_of_month);
      
      buf.append('-');
      buf.append(HttpFields.MONTHS[month]);
      buf.append('-');
      StringUtil.append2digits(buf, year / 100);
      StringUtil.append2digits(buf, year % 100);
      
      buf.append(' ');
      StringUtil.append2digits(buf, hours);
      buf.append(':');
      StringUtil.append2digits(buf, minutes);
      buf.append(':');
      StringUtil.append2digits(buf, seconds);
      buf.append(" GMT");
    }
  }
  
  public static String formatDate(long date)
  {
    return ((DateGenerator)__dateGenerator.get()).formatDate(date);
  }
  
  public static void formatCookieDate(StringBuilder buf, long date)
  {
    ((DateGenerator)__dateGenerator.get()).formatCookieDate(buf, date);
  }
  
  public static String formatCookieDate(long date)
  {
    StringBuilder buf = new StringBuilder(28);
    formatCookieDate(buf, date);
    return buf.toString();
  }
  
  private static class DateParser
  {
    final SimpleDateFormat[] _dateReceive = new SimpleDateFormat[HttpFields.__dateReceiveFmt.length];
    
    long parse(String dateVal)
    {
      for (int i = 0; i < _dateReceive.length; i++)
      {
        if (_dateReceive[i] == null)
        {
          _dateReceive[i] = new SimpleDateFormat(HttpFields.__dateReceiveFmt[i], Locale.US);
          _dateReceive[i].setTimeZone(HttpFields.__GMT);
        }
        try
        {
          Date date = (Date)_dateReceive[i].parseObject(dateVal);
          return date.getTime();
        }
        catch (Exception e) {}
      }
      if (dateVal.endsWith(" GMT"))
      {
        String val = dateVal.substring(0, dateVal.length() - 4);
        for (int i = 0; i < _dateReceive.length; i++) {
          try
          {
            Date date = (Date)_dateReceive[i].parseObject(val);
            return date.getTime();
          }
          catch (Exception e) {}
        }
      }
      return -1L;
    }
  }
  
  public static long parseDate(String date)
  {
    return ((DateParser)__dateParser.get()).parse(date);
  }
  
  private final ArrayList<Field> _fields = new ArrayList(20);
  private final HashMap<Buffer, Field> _names = new HashMap(32);
  private static ConcurrentMap<String, Buffer> __cache;
  private static int __cacheSize;
  private static final Float __one;
  private static final Float __zero;
  private static final StringMap __qualities;
  
  private Buffer convertValue(String value)
  {
    Buffer buffer = (Buffer)__cache.get(value);
    if (buffer != null) {
      return buffer;
    }
    try
    {
      buffer = new ByteArrayBuffer(value, "ISO-8859-1");
      Buffer b;
      if (__cacheSize > 0)
      {
        if (__cache.size() > __cacheSize) {
          __cache.clear();
        }
        b = (Buffer)__cache.putIfAbsent(value, buffer);
        if (b == null) {}
      }
      return b;
    }
    catch (UnsupportedEncodingException e)
    {
      throw new RuntimeException(e);
    }
  }
  
  public Collection<String> getFieldNamesCollection()
  {
    List<String> list = new ArrayList(_fields.size());
    for (Field f : _fields) {
      if (f != null) {
        list.add(BufferUtil.to8859_1_String(_name));
      }
    }
    return list;
  }
  
  public Enumeration<String> getFieldNames()
  {
    final Enumeration<?> buffers = Collections.enumeration(_names.keySet());
    new Enumeration()
    {
      public String nextElement()
      {
        return buffers.nextElement().toString();
      }
      
      public boolean hasMoreElements()
      {
        return buffers.hasMoreElements();
      }
    };
  }
  
  public int size()
  {
    return _fields.size();
  }
  
  public Field getField(int i)
  {
    return (Field)_fields.get(i);
  }
  
  private Field getField(String name)
  {
    return (Field)_names.get(HttpHeaders.CACHE.lookup(name));
  }
  
  private Field getField(Buffer name)
  {
    return (Field)_names.get(HttpHeaders.CACHE.lookup(name));
  }
  
  public boolean containsKey(Buffer name)
  {
    return _names.containsKey(HttpHeaders.CACHE.lookup(name));
  }
  
  public boolean containsKey(String name)
  {
    return _names.containsKey(HttpHeaders.CACHE.lookup(name));
  }
  
  public String getStringField(String name)
  {
    Field field = getField(name);
    return field == null ? null : field.getValue();
  }
  
  public String getStringField(Buffer name)
  {
    Field field = getField(name);
    return field == null ? null : field.getValue();
  }
  
  public Buffer get(Buffer name)
  {
    Field field = getField(name);
    return field == null ? null : _value;
  }
  
  public Collection<String> getValuesCollection(String name)
  {
    Field field = getField(name);
    if (field == null) {
      return null;
    }
    List<String> list = new ArrayList();
    while (field != null)
    {
      list.add(field.getValue());
      field = _next;
    }
    return list;
  }
  
  public Enumeration<String> getValues(String name)
  {
    final Field field = getField(name);
    if (field == null)
    {
      List<String> empty = Collections.emptyList();
      return Collections.enumeration(empty);
    }
    new Enumeration()
    {
      HttpFields.Field f = field;
      
      public boolean hasMoreElements()
      {
        return f != null;
      }
      
      public String nextElement()
        throws NoSuchElementException
      {
        if (f == null) {
          throw new NoSuchElementException();
        }
        HttpFields.Field n = f;
        f = HttpFields.Field.access$700(f);
        return n.getValue();
      }
    };
  }
  
  public Enumeration<String> getValues(Buffer name)
  {
    final Field field = getField(name);
    if (field == null)
    {
      List<String> empty = Collections.emptyList();
      return Collections.enumeration(empty);
    }
    new Enumeration()
    {
      HttpFields.Field f = field;
      
      public boolean hasMoreElements()
      {
        return f != null;
      }
      
      public String nextElement()
        throws NoSuchElementException
      {
        if (f == null) {
          throw new NoSuchElementException();
        }
        HttpFields.Field n = f;
        f = HttpFields.Field.access$700(f);
        return n.getValue();
      }
    };
  }
  
  public Enumeration<String> getValues(String name, final String separators)
  {
    final Enumeration<String> e = getValues(name);
    if (e == null) {
      return null;
    }
    new Enumeration()
    {
      QuotedStringTokenizer tok = null;
      
      public boolean hasMoreElements()
      {
        if ((tok != null) && (tok.hasMoreElements())) {
          return true;
        }
        while (e.hasMoreElements())
        {
          String value = (String)e.nextElement();
          tok = new QuotedStringTokenizer(value, separators, false, false);
          if (tok.hasMoreElements()) {
            return true;
          }
        }
        tok = null;
        return false;
      }
      
      public String nextElement()
        throws NoSuchElementException
      {
        if (!hasMoreElements()) {
          throw new NoSuchElementException();
        }
        String next = (String)tok.nextElement();
        if (next != null) {
          next = next.trim();
        }
        return next;
      }
    };
  }
  
  public void put(String name, String value)
  {
    if (value == null)
    {
      remove(name);
    }
    else
    {
      Buffer n = HttpHeaders.CACHE.lookup(name);
      Buffer v = convertValue(value);
      put(n, v);
    }
  }
  
  public void put(Buffer name, String value)
  {
    Buffer n = HttpHeaders.CACHE.lookup(name);
    Buffer v = convertValue(value);
    put(n, v);
  }
  
  public void put(Buffer name, Buffer value)
  {
    remove(name);
    if (value == null) {
      return;
    }
    if (!(name instanceof BufferCache.CachedBuffer)) {
      name = HttpHeaders.CACHE.lookup(name);
    }
    if (!(value instanceof BufferCache.CachedBuffer)) {
      value = HttpHeaderValues.CACHE.lookup(value).asImmutableBuffer();
    }
    Field field = new Field(name, value, null);
    _fields.add(field);
    _names.put(name, field);
  }
  
  public void put(String name, List<?> list)
  {
    if ((list == null) || (list.size() == 0))
    {
      remove(name);
      return;
    }
    Buffer n = HttpHeaders.CACHE.lookup(name);
    
    Object v = list.get(0);
    if (v != null) {
      put(n, HttpHeaderValues.CACHE.lookup(v.toString()));
    } else {
      remove(n);
    }
    if (list.size() > 1)
    {
      Iterator<?> iter = list.iterator();
      iter.next();
      while (iter.hasNext())
      {
        v = iter.next();
        if (v != null) {
          put(n, HttpHeaderValues.CACHE.lookup(v.toString()));
        }
      }
    }
  }
  
  public void add(String name, String value)
    throws IllegalArgumentException
  {
    if (value == null) {
      return;
    }
    Buffer n = HttpHeaders.CACHE.lookup(name);
    Buffer v = convertValue(value);
    add(n, v);
  }
  
  public void add(Buffer name, Buffer value)
    throws IllegalArgumentException
  {
    if (value == null) {
      throw new IllegalArgumentException("null value");
    }
    if (!(name instanceof BufferCache.CachedBuffer)) {
      name = HttpHeaders.CACHE.lookup(name);
    }
    name = name.asImmutableBuffer();
    if ((!(value instanceof BufferCache.CachedBuffer)) && (HttpHeaderValues.hasKnownValues(HttpHeaders.CACHE.getOrdinal(name)))) {
      value = HttpHeaderValues.CACHE.lookup(value);
    }
    value = value.asImmutableBuffer();
    
    Field field = (Field)_names.get(name);
    Field last = null;
    while (field != null)
    {
      last = field;
      field = _next;
    }
    field = new Field(name, value, null);
    _fields.add(field);
    if (last != null) {
      _next = field;
    } else {
      _names.put(name, field);
    }
  }
  
  public void remove(String name)
  {
    remove(HttpHeaders.CACHE.lookup(name));
  }
  
  public void remove(Buffer name)
  {
    if (!(name instanceof BufferCache.CachedBuffer)) {
      name = HttpHeaders.CACHE.lookup(name);
    }
    Field field = (Field)_names.remove(name);
    while (field != null)
    {
      _fields.remove(field);
      field = _next;
    }
  }
  
  public long getLongField(String name)
    throws NumberFormatException
  {
    Field field = getField(name);
    return field == null ? -1L : field.getLongValue();
  }
  
  public long getLongField(Buffer name)
    throws NumberFormatException
  {
    Field field = getField(name);
    return field == null ? -1L : field.getLongValue();
  }
  
  public long getDateField(String name)
  {
    Field field = getField(name);
    if (field == null) {
      return -1L;
    }
    String val = valueParameters(BufferUtil.to8859_1_String(_value), null);
    if (val == null) {
      return -1L;
    }
    long date = ((DateParser)__dateParser.get()).parse(val);
    if (date == -1L) {
      throw new IllegalArgumentException("Cannot convert date: " + val);
    }
    return date;
  }
  
  public void putLongField(Buffer name, long value)
  {
    Buffer v = BufferUtil.toBuffer(value);
    put(name, v);
  }
  
  public void putLongField(String name, long value)
  {
    Buffer n = HttpHeaders.CACHE.lookup(name);
    Buffer v = BufferUtil.toBuffer(value);
    put(n, v);
  }
  
  public void addLongField(String name, long value)
  {
    Buffer n = HttpHeaders.CACHE.lookup(name);
    Buffer v = BufferUtil.toBuffer(value);
    add(n, v);
  }
  
  public void addLongField(Buffer name, long value)
  {
    Buffer v = BufferUtil.toBuffer(value);
    add(name, v);
  }
  
  public void putDateField(Buffer name, long date)
  {
    String d = formatDate(date);
    Buffer v = new ByteArrayBuffer(d);
    put(name, v);
  }
  
  public void putDateField(String name, long date)
  {
    Buffer n = HttpHeaders.CACHE.l
1 2 3 4 5 6

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd