Skip to content

Commit

Permalink
Bug fix - content
Browse files Browse the repository at this point in the history
  • Loading branch information
viniciussanchez committed Feb 7, 2022
1 parent 568a644 commit 6f5218b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 21 deletions.
4 changes: 2 additions & 2 deletions boss-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
},
"github.com/hashload/horse": {
"name": "horse",
"version": "2.0.10",
"hash": "42db84faa442a8f649355ca4f9bbf433",
"version": "v2.0.14",
"hash": "38c6bebdc7b9712d6e5856d299289a26",
"artifacts": {},
"failed": false,
"changed": false
Expand Down
32 changes: 13 additions & 19 deletions src/Horse.Logger.Manager.pas
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,14 @@
interface

uses

{$IFDEF FPC }
SysUtils, Classes, SyncObjs, Generics.Collections, fpjson,
{$ELSE}
System.SysUtils, System.JSON, System.SyncObjs, System.Classes, System.Generics.Collections,
{$ENDIF}
Horse.Logger.Types, Horse.Logger.Provider.Contract, Horse,
Horse.Logger.Thread;
Horse.Logger.Types, Horse.Logger.Provider.Contract, Horse, Horse.Logger.Thread;

type

THorseLoggerManager = class;
THorseLoggerManagerClass = class of THorseLoggerManager;

Expand Down Expand Up @@ -100,22 +97,19 @@ procedure DefaultHorseCallback(AReq: THorseRequest; ARes: THorseResponse; ANext:
LLog.{$IFDEF FPC}Add{$ELSE}AddPair{$ENDIF}('response_content_encoding', THorseLoggerManager.ValidateValue(ARes.RawWebResponse.ContentEncoding));
LLog.{$IFDEF FPC}Add{$ELSE}AddPair{$ENDIF}('response_content_type', THorseLoggerManager.ValidateValue(ARes.RawWebResponse.ContentType));
LLog.{$IFDEF FPC}Add{$ELSE}AddPair{$ENDIF}('response_content_length', THorseLoggerManager.ValidateValue(ARes.RawWebResponse.ContentLength.ToString));
if (not Assigned(ARes.Content)) or (not ARes.Content.InheritsFrom({$IF DEFINED(FPC)}TJsonData{$ELSE}TJSONValue{$ENDIF})) then
LLog.{$IFDEF FPC}Add{$ELSE}AddPair{$ENDIF}('response_content', THorseLoggerManager.ValidateValue(ARes.RawWebResponse.Content))
else
LLog.{$IFDEF FPC}Add{$ELSE}AddPair{$ENDIF}('response_content', THorseLoggerManager.ValidateValue({$IF DEFINED(FPC)}TJsonData(ARes.Content).AsJSON{$ELSE}TJSONValue(ARes.Content).ToJSON{$ENDIF}));
LLog.{$IFDEF FPC}Add{$ELSE}AddPair{$ENDIF}('response_content', THorseLoggerManager.ValidateValue(ARes.RawWebResponse.Content));
LLog.{$IFDEF FPC}Add{$ELSE}AddPair{$ENDIF}('response_status', THorseLoggerManager.ValidateValue(ARes.RawWebResponse.{$IF DEFINED(FPC)}Code.ToString(){$ELSE}StatusCode.ToString{$ENDIF}));
{$IF NOT DEFINED(FPC)}
LLog.AddPair('request_derived_from', THorseLoggerManager.ValidateValue(AReq.RawWebRequest.DerivedFrom));
LLog.AddPair('request_remote_ip', THorseLoggerManager.ValidateValue(AReq.RawWebRequest.RemoteIP));
LLog.AddPair('request_internal_path_info', THorseLoggerManager.ValidateValue(AReq.RawWebRequest.InternalPathInfo));
LLog.AddPair('request_raw_path_info', THorseLoggerManager.ValidateValue(AReq.RawWebRequest.RawPathInfo));
LLog.AddPair('request_cache_control', THorseLoggerManager.ValidateValue(AReq.RawWebRequest.CacheControl));
LLog.AddPair('response_realm', THorseLoggerManager.ValidateValue(ARes.RawWebResponse.Realm));
LLog.AddPair('response_log_message', THorseLoggerManager.ValidateValue(ARes.RawWebResponse.LogMessage));
LLog.AddPair('response_title', THorseLoggerManager.ValidateValue(ARes.RawWebResponse.Title));
LLog.AddPair('response_content_version', THorseLoggerManager.ValidateValue(ARes.RawWebResponse.ContentVersion));
{$ENDIF}
{$IF NOT DEFINED(FPC)}
LLog.AddPair('request_derived_from', THorseLoggerManager.ValidateValue(AReq.RawWebRequest.DerivedFrom));
LLog.AddPair('request_remote_ip', THorseLoggerManager.ValidateValue(AReq.RawWebRequest.RemoteIP));
LLog.AddPair('request_internal_path_info', THorseLoggerManager.ValidateValue(AReq.RawWebRequest.InternalPathInfo));
LLog.AddPair('request_raw_path_info', THorseLoggerManager.ValidateValue(AReq.RawWebRequest.RawPathInfo));
LLog.AddPair('request_cache_control', THorseLoggerManager.ValidateValue(AReq.RawWebRequest.CacheControl));
LLog.AddPair('response_realm', THorseLoggerManager.ValidateValue(ARes.RawWebResponse.Realm));
LLog.AddPair('response_log_message', THorseLoggerManager.ValidateValue(ARes.RawWebResponse.LogMessage));
LLog.AddPair('response_title', THorseLoggerManager.ValidateValue(ARes.RawWebResponse.Title));
LLog.AddPair('response_content_version', THorseLoggerManager.ValidateValue(ARes.RawWebResponse.ContentVersion));
{$ENDIF}
finally
THorseLoggerManager.GetDefaultManager.NewLog(LLog);
end;
Expand Down

0 comments on commit 6f5218b

Please sign in to comment.