Hey iktomi,
To begin, I am testing in 4.13 Release without your change.
So I put together 2 projects, one on Mac one and PC, so I could see if there was any differences. This is my result:
First, this was the test URL that has a ETag that will return 304 if If-None-Match header is set. As a note, if it is not set, normal 200 returns. [https://httpbin.org/cache][1]
Secondly, I setup the project to be ready for Http requests, which means adding the following the Game.Build.cs:
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "Http" )};
Then, I created a Actor I can call to send the request:
[.h]
#pragma once
#include "GameFramework/Actor.h"
#include "Runtime/Online/HTTP/Public/Http.h"
#include "HTTPActor.generated.h"
UCLASS()
class AH492514_API AHTTPActor : public AActor
{
GENERATED_BODY()
public:
AHTTPActor();
virtual void BeginPlay() override;
virtual void Tick( float DeltaSeconds ) override;
UFUNCTION( BlueprintCallable, Category = "HTTP" )
void CallHttp( const FString URL );
void OnResponseRecieved( FHttpRequestPtr Request, FHttpResponsePtr Response, bool bSuccessful );
FHttpModule* Http;
};
[.cpp]
#include "AH492514.h"
#include "HTTPActor.h"
AHTTPActor::AHTTPActor()
{
PrimaryActorTick.bCanEverTick = true;
Http = &FHttpModule::Get( );
}
void AHTTPActor::BeginPlay()
{
Super::BeginPlay();
}
void AHTTPActor::Tick( float DeltaTime )
{
Super::Tick( DeltaTime );
}
void AHTTPActor::CallHttp( const FString URL )
{
TSharedRef<IHttpRequest> Request = Http->CreateRequest( );
Request->OnProcessRequestComplete( ).BindUObject( this, &AHTTPActor::OnResponseRecieved );
Request->SetURL( URL );
Request->SetVerb( "GET" );
Request->SetHeader( TEXT("User-Agent"), "X-UnrealEngine-Agent" );
Request->SetHeader( "Content-Type", TEXT( "application/json" ) );
Request->SetHeader( TEXT( "If-None-Match" ), "ETag" );
Request->ProcessRequest( );
}
void AHTTPActor::OnResponseRecieved( FHttpRequestPtr Request, FHttpResponsePtr Response, bool bSuccessful )
{
TArray<FString> RequestHeaders = Request->GetAllHeaders();
for( int i = 0; i < RequestHeaders.Num(); i++ )
{
UE_LOG( LogTemp, Warning, TEXT("Request Header: %s"), *RequestHeaders[ i ] );
}
int32 ResponseCode = Response->GetResponseCode();
UE_LOG(LogTemp, Error, TEXT("ResponseCode: %d"), ResponseCode);
TArray<FString> ResponseHeaders = Response->GetAllHeaders( );
for( int j = 0; j < ResponseHeaders.Num(); j++ )
{
UE_LOG( LogTemp, Warning, TEXT("Response Header: %s"), *ResponseHeaders[ j ] );
}
}
I then setup Blueprint to create the Actor and then call the CallHttp( ) function, like this:
This, results in the ProcessRequest with the SetHeaders( ) to respond with:
[PC and Mac]
LogTemp:Warning: Request Header: User-Agent: X-UnrealEngine-Agent
LogTemp:Warning: Request Header: Content-Type: application/json
LogTemp:Warning: Request Header: If-None-Match: ETag
LogTemp:Warning: Request Header: Content-Length: 0
LogTemp:Warning: Request Header: Pragma: no-cache
LogTemp:Warning: Request Header: Expect:
**LogTemp:Error: ResponseCode: 304**
LogTemp:Warning: Response Header: Server: nginx
LogTemp:Warning: Response Header: Date: Thu, 22 Sep 2016 14:42:50 GMT
LogTemp:Warning: Response Header: Connection: keep-alive
LogTemp:Warning: Response Header: Access-Control-Allow-Origin: *
LogTemp:Warning: Response Header: Access-Control-Allow-Credentials: true
As you can see, I am not seeing the same result as what you are describing. If you give me anymore information as to your report, I can investigate further but as of now, we do not believe this to be a bug with the Unreal Engine.