From 801e8f7165ef5752ac6c02b3170f6fa6401c1e14 Mon Sep 17 00:00:00 2001 From: zorigoo0128 Date: Fri, 29 Apr 2022 16:29:31 +0800 Subject: [PATCH 1/4] Added custom header support (such as Auth, User-agent, Connection) --- Source/VaRest/Private/VaRestSubsystem.cpp | 7 ++++++- Source/VaRest/Public/VaRestSubsystem.h | 5 +++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Source/VaRest/Private/VaRestSubsystem.cpp b/Source/VaRest/Private/VaRestSubsystem.cpp index 97daab65..4fd5f1b3 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, 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 6a438d65..15de8c3b 100644 --- a/Source/VaRest/Public/VaRestSubsystem.h +++ b/Source/VaRest/Public/VaRestSubsystem.h @@ -15,10 +15,11 @@ DECLARE_DYNAMIC_DELEGATE_OneParam(FVaRestCallDelegate, UVaRestRequestJSON*, Requ USTRUCT() struct FVaRestCallResponse { - GENERATED_BODY() + GENERATED_USTRUCT_BODY() 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, TMap headers, EVaRestRequestContentType ContentType, UVaRestJsonObject* VaRestJson, const FVaRestCallDelegate& Callback); /** Called when URL is processed (one for both success/unsuccess events)*/ void OnCallComplete(UVaRestRequestJSON* Request); From d67e54eb33f57d298b531d6821d1a6e8f69a0af9 Mon Sep 17 00:00:00 2001 From: zorigoo0128 Date: Tue, 17 May 2022 17:20:02 +0800 Subject: [PATCH 2/4] fixed custom headers --- Source/VaRest/Private/VaRestSubsystem.cpp | 6 +++--- Source/VaRest/Public/VaRestSubsystem.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Source/VaRest/Private/VaRestSubsystem.cpp b/Source/VaRest/Private/VaRestSubsystem.cpp index 4fd5f1b3..2a34e924 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, TMap headers, 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) @@ -45,9 +45,9 @@ void UVaRestSubsystem::CallURL(const FString& URL, EVaRestRequestVerb Verb, TMap 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 15de8c3b..d609b0d6 100644 --- a/Source/VaRest/Public/VaRestSubsystem.h +++ b/Source/VaRest/Public/VaRestSubsystem.h @@ -15,7 +15,7 @@ DECLARE_DYNAMIC_DELEGATE_OneParam(FVaRestCallDelegate, UVaRestRequestJSON*, Requ USTRUCT() struct FVaRestCallResponse { - GENERATED_USTRUCT_BODY() + GENERATED_BODY() UPROPERTY() UVaRestRequestJSON* Request; @@ -52,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, TMap headers, 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); From 3728b5d15be19cc412867b86f99d08aee90427d5 Mon Sep 17 00:00:00 2001 From: zorigoo0128 Date: Mon, 20 Jun 2022 10:59:10 +0800 Subject: [PATCH 3/4] Added const ref --- Source/VaRest/Private/VaRestSubsystem.cpp | 2 +- Source/VaRest/Public/VaRestSubsystem.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/VaRest/Private/VaRestSubsystem.cpp b/Source/VaRest/Private/VaRestSubsystem.cpp index 2a34e924..3aeca70b 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, const TMap headers, 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) diff --git a/Source/VaRest/Public/VaRestSubsystem.h b/Source/VaRest/Public/VaRestSubsystem.h index d609b0d6..66e6499d 100644 --- a/Source/VaRest/Public/VaRestSubsystem.h +++ b/Source/VaRest/Public/VaRestSubsystem.h @@ -52,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, const TMap headers, 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); From 0eb210ad8dee5db8b08b4b3a58b47a97a65c0cca Mon Sep 17 00:00:00 2001 From: zorigoo0128 Date: Mon, 10 Apr 2023 18:54:01 +0800 Subject: [PATCH 4/4] Updated to 5.1 --- VaRest.uplugin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VaRest.uplugin b/VaRest.uplugin index 9b0df62a..fed7a81b 100644 --- a/VaRest.uplugin +++ b/VaRest.uplugin @@ -6,7 +6,7 @@ "VersionName" : "1.1-r32", "CreatedBy" : "Vladimir Alyamkin", "CreatedByURL" : "https://ufna.dev", - "EngineVersion" : "5.2.0", + "EngineVersion" : "5.1.0", "Description" : "Plugin that makes REST (JSON) server communication easy to use", "Category" : "Network", "DocsURL": "https://bit.ly/VaRest-Docs",