// Path: src/main/java/info/jdavid/ok/server/header/CacheControl.java
// @SuppressWarnings({ "WeakerAccess" })
// public final class CacheControl {
// 
//   private CacheControl() {}
// 
//   /**
//    * Cache-Control header field name.
//    */
//   public static final String HEADER = "Cache-Control";
//   /**
//    * Expires header field name.
//    */
//   public static final String EXPIRES = "Expires";
// 
// 
//   /**
//    * Cache-Control directive.
//    */
//   @SuppressWarnings("unused")
//   public static class Directive {
// 
//     private Directive() {}
// 
//     /**
//      * The response should not be stored in the cache.
//      */
//     public static final String NO_STORE = "no-store";
//     /**
//      * The response should be stored as-is in the cache. No transformation (usually by a proxy) is allowed.
//      */
//     public static final String NO_TRANSFORM = "no-transform";
//     /**
//      * The response can be cached publicly, including in shared caches (at the proxy level).
//      */
//     public static final String PUBLIC = "public";
//     /**
//      * The response can only be cached for the current user, but not in shared caches (at the proxy level).
//      */
//     public static final String PRIVATE = "private";
// 
//     /**
//      * A client should revalidate the response with the server before returning the cached response.
//      */
//     public static final String NO_CACHE = "no-cache";
//     /**
//      * A client should revalidate a stale cached response (max-age expired) with the server
//      * before returning it.
//      */
//     public static final String MUST_REVALIDATE = "must-revalidate";
//     /**
//      * Same as must-revalidate, but only for public (shared) caches. It does not apply to private cache.
//      */
//     public static final String PROXY_REVALIDATE = "proxy-revalidate";
//     /**
//      * A client should response with a cached response, or with a 504 (gateway timeout).
//      */
//     public static final String ONLY_IF_CACHED = "only-if-cached";
//     /**
//      * A client should consider the response stale once the max-age is expired.
//      */
//     public static final String MAX_AGE_EQUALS = "max-age=";
//     /**
//      * s-maxage overrides max-age and the Expires header value for public (shared) caches.
//      */
//     public static final String S_MAX_AGE_EQUALS = "s-maxage=";
//     /**
//      * A clients should revalidate a stale cached response (max-age expired) with the server, but it can
//      * return the cached response if its max-age is lower than the specified limit.
//      */
//     public static final String STALE_WHILE_REVALIDATE_EQUALS = "stale-while-revalidate=";
//     /**
//      * A client should revalidate a stale cached response (max-age expired) with the server, but it can
//      * return the cached response if thevalidation call fails and the cached response max-age is lower than
//      * the specified limit.
//      */
//     public static final String STALE_IF_ERROR_EQUALS = "stale-if-error=";
//     /**
//      * A client should consider that a cached response that is not stale has not changed and should not
//      * revalidate it with the server.
//      */
//     public static final String IMMUTABLE = "immutable";
// 
//   }
// 
// }
// 
// Path: src/main/java/info/jdavid/ok/server/header/Cors.java
// @SuppressWarnings({ "WeakerAccess", "unused" })
// public final class Cors {
// 
//   private Cors() {}
// 
//   public static final String ALLOW_ORIGIN = "Access-Control-Allow-Origin";
//   public static final String ALLOW_METHODS = "Access-Control-Allow-Methods";
//   public static final String ALLOW_HEADERS = "Access-Control-Allow-Headers";
//   public static final String MAX_AGE = "Access-Control-Max-Age";
//   public static final String EXPOSE_HEADERS = "Access-Control-Expose-Headers";
// 
// }
// 
// Path: src/main/java/info/jdavid/ok/server/header/ETag.java
// @SuppressWarnings({ "WeakerAccess" })
// public final class ETag {
// 
//   private ETag() {}
// 
//   public static final String HEADER = "ETag";
// 
//   public static final String IF_MATCH = "If-Match";
//   public static final String IF_NONE_MATCH = "If-None-Match";
// 
// }


import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import javax.annotation.Nullable;
import info.jdavid.ok.server.header.CacheControl;
import info.jdavid.ok.server.header.Cors;
import info.jdavid.ok.server.header.ETag;
import okhttp3.Headers;
import okhttp3.HttpUrl;
import okhttp3.MediaType;
import okhttp3.Protocol;
import okhttp3.ResponseBody;
import okhttp3.internal.http.StatusLine;
import okio.Buffer;
import okio.BufferedSink;
import okio.BufferedSource;
    public Builder() {}

    /**
     * Sets the status line.
     * @param statusLine the status line.
     * @return this
     */
    public Builder statusLine(final StatusLine statusLine) {
      protocol = statusLine.protocol;
      code = statusLine.code;
      message = statusLine.message;
      return this;
    }

    /**
     * Gets the http response status code.
     * @return the status code.
     */
    public int code() {
      if (code == -1) throw new IllegalStateException("The status line has not been set.");
      return code;
    }

    /**
     * Sets the etag (optional) and the cache control header to no-cache.
     * @param etag the etag (optional).
     * @return this
     */
    public Builder noCache(@Nullable final String etag) {
      if (etag != null) headers.set(ETag.HEADER, etag);
// Path: src/main/java/info/jdavid/ok/server/header/CacheControl.java
// @SuppressWarnings({ "WeakerAccess" })
// public final class CacheControl {
// 
//   private CacheControl() {}
// 
//   /**
//    * Cache-Control header field name.
//    */
//   public static final String HEADER = "Cache-Control";
//   /**
//    * Expires header field name.
//    */
//   public static final String EXPIRES = "Expires";
// 
// 
//   /**
//    * Cache-Control directive.
//    */
//   @SuppressWarnings("unused")
//   public static class Directive {
// 
//     private Directive() {}
// 
//     /**
//      * The response should not be stored in the cache.
//      */
//     public static final String NO_STORE = "no-store";
//     /**
//      * The response should be stored as-is in the cache. No transformation (usually by a proxy) is allowed.
//      */
//     public static final String NO_TRANSFORM = "no-transform";
//     /**
//      * The response can be cached publicly, including in shared caches (at the proxy level).
//      */
//     public static final String PUBLIC = "public";
//     /**
//      * The response can only be cached for the current user, but not in shared caches (at the proxy level).
//      */
//     public static final String PRIVATE = "private";
// 
//     /**
//      * A client should revalidate the response with the server before returning the cached response.
//      */
//     public static final String NO_CACHE = "no-cache";
//     /**
//      * A client should revalidate a stale cached response (max-age expired) with the server
//      * before returning it.
//      */
//     public static final String MUST_REVALIDATE = "must-revalidate";
//     /**
//      * Same as must-revalidate, but only for public (shared) caches. It does not apply to private cache.
//      */
//     public static final String PROXY_REVALIDATE = "proxy-revalidate";
//     /**
//      * A client should response with a cached response, or with a 504 (gateway timeout).
//      */
//     public static final String ONLY_IF_CACHED = "only-if-cached";
//     /**
//      * A client should consider the response stale once the max-age is expired.
//      */
//     public static final String MAX_AGE_EQUALS = "max-age=";
//     /**
//      * s-maxage overrides max-age and the Expires header value for public (shared) caches.
//      */
//     public static final String S_MAX_AGE_EQUALS = "s-maxage=";
//     /**
//      * A clients should revalidate a stale cached response (max-age expired) with the server, but it can
//      * return the cached response if its max-age is lower than the specified limit.
//      */
//     public static final String STALE_WHILE_REVALIDATE_EQUALS = "stale-while-revalidate=";
//     /**
//      * A client should revalidate a stale cached response (max-age expired) with the server, but it can
//      * return the cached response if thevalidation call fails and the cached response max-age is lower than
//      * the specified limit.
//      */
//     public static final String STALE_IF_ERROR_EQUALS = "stale-if-error=";
//     /**
//      * A client should consider that a cached response that is not stale has not changed and should not
//      * revalidate it with the server.
//      */
//     public static final String IMMUTABLE = "immutable";
// 
//   }
// 
// }
// 
// Path: src/main/java/info/jdavid/ok/server/header/Cors.java
// @SuppressWarnings({ "WeakerAccess", "unused" })
// public final class Cors {
// 
//   private Cors() {}
// 
//   public static final String ALLOW_ORIGIN = "Access-Control-Allow-Origin";
//   public static final String ALLOW_METHODS = "Access-Control-Allow-Methods";
//   public static final String ALLOW_HEADERS = "Access-Control-Allow-Headers";
//   public static final String MAX_AGE = "Access-Control-Max-Age";
//   public static final String EXPOSE_HEADERS = "Access-Control-Expose-Headers";
// 
// }
// 
// Path: src/main/java/info/jdavid/ok/server/header/ETag.java
// @SuppressWarnings({ "WeakerAccess" })
// public final class ETag {
// 
//   private ETag() {}
// 
//   public static final String HEADER = "ETag";
// 
//   public static final String IF_MATCH = "If-Match";
//   public static final String IF_NONE_MATCH = "If-None-Match";
// 
// }


// Path: src/main/java/info/jdavid/ok/server/Response.java
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import javax.annotation.Nullable;
import info.jdavid.ok.server.header.CacheControl;
import info.jdavid.ok.server.header.Cors;
import info.jdavid.ok.server.header.ETag;
import okhttp3.Headers;
import okhttp3.HttpUrl;
import okhttp3.MediaType;
import okhttp3.Protocol;
import okhttp3.ResponseBody;
import okhttp3.internal.http.StatusLine;
import okio.Buffer;
import okio.BufferedSink;
import okio.BufferedSource;

    public Builder() {}

    /**
     * Sets the status line.
     * @param statusLine the status line.
     * @return this
     */
    public Builder statusLine(final StatusLine statusLine) {
      protocol = statusLine.protocol;
      code = statusLine.code;
      message = statusLine.message;
      return this;
    }

    /**
     * Gets the http response status code.
     * @return the status code.
     */
    public int code() {
      if (code == -1) throw new IllegalStateException("The status line has not been set.");
      return code;
    }

    /**
     * Sets the etag (optional) and the cache control header to no-cache.
     * @param etag the etag (optional).
     * @return this
     */
    public Builder noCache(@Nullable final String etag) {
      if (etag != null) headers.set(ETag.HEADER, etag);
      headers.set(CacheControl.HEADER, "no-cache");