anchor.diff:              exit(normal)
       end.
   
  +read_sub_chunks(Length, MaxChunkSize, Fun, FunState) when Length > MaxChunkSize ->
  +    Bin = recv(MaxChunkSize),
  +    NewState = Fun({size(Bin), Bin}, FunState),
  +    read_sub_chunks(Length - MaxChunkSize, MaxChunkSize, Fun, NewState);
  +
  +read_sub_chunks(Length, _MaxChunkSize, Fun, FunState) ->
  +    Fun({Length, read_chunk(Length)}, FunState).
  +    
   %% @spec serve_file(Path, DocRoot) -> Response
   %% @doc Serve a file relative to DocRoot.
   serve_file(Path, DocRoot) ->
  
positive.code: -define(READ_SIZE, 8192).
  
  -export([get_header_value/1, get_primary_header_value/1, get/1, dump/0]).
  -export([send/1, recv/1, recv/2, recv_body/0, recv_body/1]).
  -export([start_response/1, start_response_length/1, start_raw_response/1]).
  -export([respond/1, ok/1]).
  -export([not_found/0, not_found/1]).
  
negative.code:             Cached
      end.
  
  %% @spec stream_chunked_body(integer(), fun(), term()) -> term()
  %% @doc The function is called for each chunk.
  %%      Used internally by read_chunked_body.
  stream_chunked_body(MaxChunkSize, Fun, FunState) ->
      case read_chunk_length() of
          0 ->
              Fun({0, read_chunk(0)}, FunState);
          Length when Length > MaxChunkSize ->
              NewState = read_sub_chunks(Length, MaxChunkSize, Fun, FunState),
              stream_chunked_body(MaxChunkSize, Fun, NewState);
          Length ->
              NewState = Fun({Length, read_chunk(Length)}, FunState),
              stream_chunked_body(MaxChunkSize, Fun, NewState)
      end.
  
  stream_unchunked_body(0, _MaxChunkSize, Fun, FunState) ->
      Fun({0, <<>>}, FunState);
  stream_unchunked_body(Length, MaxChunkSize, Fun, FunState) when Length > MaxChunkSize ->
      Bin = recv(MaxChunkSize),
      NewState = Fun({MaxChunkSize, Bin}, FunState),
      stream_unchunked_body(Length - MaxChunkSize, MaxChunkSize, Fun, NewState);
  stream_unchunked_body(Length, MaxChunkSize, Fun, FunState) ->
      Bin = recv(Length),
      NewState = Fun({Length, Bin}, FunState),
      stream_unchunked_body(0, MaxChunkSize, Fun, NewState).
  
  
  %% @spec read_chunk_length() -> integer()
  %% @doc Read the length of the next HTTP chunk.
  