diff --git a/Source/VaRest/Private/VaRestSubsystem.cpp b/Source/VaRest/Private/VaRestSubsystem.cpp index 97daab6..3aeca70 100644 --- a/Source/VaRest/Private/VaRestSubsystem.cpp +++ b/Source/VaRest/Private/VaRestSubsystem.cpp @@ -30,7 +30,7 @@ void UVaRestSubsystem::Deinitialize() Super::Deinitialize(); } -void UVaRestSubsystem::CallURL(const FString& URL, EVaRestRequestVerb Verb, EVaRestRequestContentType ContentType, UVaRestJsonObject* VaRestJson, const FVaRestCallDelegate& Callback) +void UVaRestSubsystem::CallURL(const FString& URL, EVaRestRequestVerb Verb, const TMap &headers, EVaRestRequestContentType ContentType, UVaRestJsonObject* VaRestJson, const FVaRestCallDelegate& Callback) { // Check we have valid data json if (VaRestJson == nullptr) @@ -43,6 +43,11 @@ void UVaRestSubsystem::CallURL(const FString& URL, EVaRestRequestVerb Verb, EVaR Request->SetVerb(Verb); Request->SetContentType(ContentType); Request->SetRequestObject(VaRestJson); + + for (const TPair& pair : headers) + { + Request->SetHeader(pair.Key, pair.Value); + } FVaRestCallResponse Response; Response.Request = Request; diff --git a/Source/VaRest/Public/VaRestSubsystem.h b/Source/VaRest/Public/VaRestSubsystem.h index 6a438d6..66e6499 100644 --- a/Source/VaRest/Public/VaRestSubsystem.h +++ b/Source/VaRest/Public/VaRestSubsystem.h @@ -19,6 +19,7 @@ struct FVaRestCallResponse UPROPERTY() UVaRestRequestJSON* Request; + UPROPERTY() FVaRestCallDelegate Callback; @@ -51,7 +52,7 @@ class VAREST_API UVaRestSubsystem : public UEngineSubsystem public: /** Easy way to process http requests */ UFUNCTION(BlueprintCallable, Category = "VaRest|Utility") - void CallURL(const FString& URL, EVaRestRequestVerb Verb, EVaRestRequestContentType ContentType, UVaRestJsonObject* VaRestJson, const FVaRestCallDelegate& Callback); + void CallURL(const FString& URL, EVaRestRequestVerb Verb, const TMap &headers, EVaRestRequestContentType ContentType, UVaRestJsonObject* VaRestJson, const FVaRestCallDelegate& Callback); /** Called when URL is processed (one for both success/unsuccess events)*/ void OnCallComplete(UVaRestRequestJSON* Request);