x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

I keep getting this error when ever I try to send my Http request c++

 //ERROR
 
 LogHttp: Warning: 00000176BB221600: request failed, libcurl error: 1 (Unsupported protocol)
 LogHttp: Warning: 00000176BB221600: libcurl info message cache 0 (Protocol "http " not supported or disabled in libcurl)
 LogHttp: Warning: 00000176BB221600: libcurl info message cache 1 (Closing connection -1)
 LogTemp: Warning: This is not valid

 //My LoginComponentClass
 // Fill out your copyright notice in the Description page of Project Settings.
 
 #include "LoginComponent.h"
 
 
 // Sets default values for this component's properties
 ULoginComponent::ULoginComponent()
 {
     // Set this component to be initialized when the game starts, and to be ticked every frame.  You can turn these features
     // off to improve performance if you don't need them.
     PrimaryComponentTick.bCanEverTick = true;
 
     
 }
 
 void ULoginComponent::BeginPlay()
 {
     Super::BeginPlay();
 
 }
 
 
 void ULoginComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
 {
     Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
     OnLoginResponse.Clear();
 }
 
 void ULoginComponent::Login(FString Username, FString Password)
 {
     //if (OnLoginResponse.IsBound()) {
     //    UE_LOG(LogTemp, Warning, TEXT("it is bound."))
     //    return;
     //}
     
     TSharedRef<IHttpRequest> request= (&FHttpModule::Get())->CreateRequest();
     FString additionalString = "Username=" + Username + "&Password=" + Password;
     
     request->SetURL(baseURL+additionalString);
     UE_LOG(LogTemp, Warning, TEXT("Your message: %s"),*request.Get().GetURL());
     request->SetVerb("POST");
     request->OnProcessRequestComplete().BindUObject(this, &ULoginComponent::ResponseRecived);
     request->ProcessRequest();
     
 }
 
 void ULoginComponent::ResponseRecived(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful)
 {
 
     if (!bWasSuccessful ||!Response.IsValid()) {
         UE_LOG(LogTemp, Warning, TEXT("This is not valid"));//This keeps on firing
         OnLoginResponse.Clear();
         return;
     }
     if (!EHttpResponseCodes::IsOk(Response->GetResponseCode())) {
         
         UE_LOG(LogTemp, Warning, TEXT("Http Response returned error code: %d"), Response->GetResponseCode());
         OnLoginResponse.Clear();
         return;
     }
 
     OnLoginResponse.Broadcast(Response->GetContentAsString());
     UE_LOG(LogTemp, Warning, TEXT("Something was returned from the response."));
     OnLoginResponse.Clear();
 }
 
 ___________________________________________________________________________________

My logincomponent header

 // Fill out your copyright notice in the Description page of Project Settings.
 
 
 
 #pragma once
 
 #include "Runtime/Online/HTTP/Public/Http.h"
 #include "CoreMinimal.h"
 #include "Components/ActorComponent.h"
 #include "LoginComponent.generated.h"
 DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FLoginResponse, FString, ResponseString);
 
 
 UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent))
 class BATTLETANK_API ULoginComponent : public UActorComponent
 {
     GENERATED_BODY()
 
 public:
     // Sets default values for this component's properties
     ULoginComponent();
     UPROPERTY(BlueprintAssignable, Category = "Login")
     FLoginResponse OnLoginResponse;
 
     
     FHttpModule* Http;
 protected:
     // Called when the game starts
     virtual void BeginPlay() override;
 
 public:
     // Called every frame
     virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
     UFUNCTION(BlueprintCallable)
     void Login(FString Username,FString Password);
     
     void ResponseRecived(FHttpRequestPtr, FHttpResponsePtr , bool );
 
 private:
     UPROPERTY(EditAnywhere, Category = "Login")
     FString baseURL = TEXT("http ://localhost:8080/login?");
 };





Product Version: UE 4.18
Tags:
more ▼

asked Jan 19 '18 at 04:02 AM in C++ Programming

avatar image

A-NASR
5 2 5

(comments are locked)
10|2000 characters needed characters left

2 answers: sort voted first

Try removing the space after "http". It should be "http:". Looks like the parser isn't removing the whitespace. Not sure if that's a deficiency or normal functionality. But either way, try getting rid of that space.

more ▼

answered Jan 19 '18 at 11:58 AM

avatar image

Jin_VE
4.3k 31 77 40

(comments are locked)
10|2000 characters needed characters left

Ty man I figured it out while I was trying new URLs . Thanks again.

more ▼

answered Jan 19 '18 at 03:05 PM

avatar image

A-NASR
5 2 5

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question