 if Code.ensure_loaded?(:ibrowse) do
   defmodule Maxwell.Adapter.Ibrowse do
-    use Maxwell.Adapter
     @moduledoc  """
     [`ibrowse`](https://github.com/cmullaparthi/ibrowse) adapter
     """
+
+    @chunk_size 5*1024*1024
+    use Maxwell.Adapter
 
     @doc """
     * `conn` - `%Maxwell.Conn{}`

                    method: method, opts: opts, req_body: req_body} = conn
      url = url_serialize(url, path, query_string)
      req_headers = header_serialize(req_headers)
      req_body = stream_encode(req_body)
      result = :ibrowse.send_req(url, req_headers, method, req_body, opts)
      format_response(result, conn)
    end

    def send_file(conn) do
      %Maxwell.Conn{url: url, req_headers: req_headers,
                    query_string: query_string, path: path,
                    method: method, opts: opts, req_body: {:file, filepath}} = conn
      url = url_serialize(url, path, query_string)
      opts = Keyword.put(opts, :transfer_encoding, :chunked) # it auto add "transfer_encodeing: chunked" header
      req_headers =
        req_headers
        |> Map.has_key?("content-type")
        |> case do
             true ->
               req_headers |> header_serialize
             false ->
               content_type = :mimerl.filename(filepath)
               req_headers
               |> Map.put("content-type", content_type)
               |> header_serialize
           end
      req_body = {&stream_iterate/1, filepath}
      result = :ibrowse.send_req(url, req_headers, method, req_body, opts)
      format_response(result, conn)
    end
