From 9bd34f364e1d9d3a02391cc3ace1ee98d84ae547 Mon Sep 17 00:00:00 2001 From: Adam Kocoloski Date: Mon, 2 Nov 2009 20:31:08 +0000 Subject: cast string status codes (from _externals) to integers before logging. COUCHDB-551 git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@832091 13f79535-47bb-0310-9956-ffa450edef68 --- src/couchdb/couch_httpd.erl | 2 +- src/couchdb/couch_util.erl | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/couchdb/couch_httpd.erl b/src/couchdb/couch_httpd.erl index 9ad39e2d..7b876cfa 100644 --- a/src/couchdb/couch_httpd.erl +++ b/src/couchdb/couch_httpd.erl @@ -375,7 +375,7 @@ log_request(#httpd{mochi_req=MochiReq,peer=Peer,method=Method}, Code) -> Peer, Method, MochiReq:get(raw_path), - Code + couch_util:to_integer(Code) ]). diff --git a/src/couchdb/couch_util.erl b/src/couchdb/couch_util.erl index 7efc07c0..cdae0d4a 100644 --- a/src/couchdb/couch_util.erl +++ b/src/couchdb/couch_util.erl @@ -19,7 +19,7 @@ -export([encodeBase64/1, decodeBase64/1, encodeBase64Url/1, decodeBase64Url/1, to_hex/1,parse_term/1, dict_find/3]). -export([file_read_size/1, get_nested_json_value/2, json_user_ctx/1]). --export([to_binary/1, to_list/1, url_encode/1]). +-export([to_binary/1, to_integer/1, to_list/1, url_encode/1]). -include("couch_db.hrl"). -include_lib("kernel/include/file.hrl"). @@ -371,6 +371,13 @@ to_binary(V) when is_atom(V) -> to_binary(V) -> list_to_binary(io_lib:format("~p", [V])). +to_integer(V) when is_integer(V) -> + V; +to_integer(V) when is_list(V) -> + erlang:list_to_integer(V); +to_integer(V) when is_binary(V) -> + erlang:list_to_integer(binary_to_list(V)). + to_list(V) when is_list(V) -> V; to_list(V) when is_binary(V) -> -- cgit v1.2.3