anchor.diff:      Host = host_for_request(Req),
       XSsl = couch_config:get("httpd", "x_forwarded_ssl", "X-Forwarded-Ssl"),
       Scheme = case MochiReq:get_header_value(XSsl) of
  -        "on" -> "https";
  -        _ ->
  -            XProto = couch_config:get("httpd", "x_forwarded_proto", "X-Forwarded-Proto"),
  -            case MochiReq:get_header_value(XProto) of
  -                % Restrict to "https" and "http" schemes only
  -                "https" -> "https";
  -                _ -> "http"
  -            end
  -    end,
  +                 "on" -> "https";
  +                 _ ->
  +                     XProto = couch_config:get("httpd", "x_forwarded_proto", "X-Forwarded-Proto"),
  +                     case MochiReq:get_header_value(XProto) of
  +                         %% Restrict to "https" and "http" schemes only
  +                         "https" -> "https";
  +                         _ -> case MochiReq:get(scheme) of
  +                                  https -> "https";
  +                                  http -> "http"
  +                              end
  +                     end
  +             end,
       Scheme ++ "://" ++ Host ++ Path.
   
   unquote(UrlEncodedString) ->
  
positive.code: -module(couch_httpd).
  -include("couch_db.hrl").
  
  -export([start_link/0, stop/0, handle_request/7]).
  
  -export([header_value/2,header_value/3,qs_value/2,qs_value/3,qs/1,path/1,absolute_uri/2,body_length/1]).
  -export([verify_is_server_admin/1,unquote/1,quote/1,recv/2,recv_chunked/4,error_info/1]).
  
negative.code: 
      % and off we go
  
      {ok, Pid} = case mochiweb_http:start(Options ++ [
          {loop, Loop},
          {name, Name},
          {ip, BindAddress}
      ]) of
      {ok, MochiPid} -> {ok, MochiPid};
      {error, Reason} ->
  