UE4/C++: FHttpModule 㧠SetContentAsString ã㦠POST ã§æãããè½ã¡ãæã®ã¡ã¢
次ã®ãããªããç°¡å㪠FHttpModule
ã®å®è£
ä¾ãå®è¡ããã¨ã²ã¼ã ã¾ã㯠UE4Editor ãã¨ããã»ã¹ãè½ã¡ã¦ãã¾ãã
TSharedRef< IHttpRequest > r = FHttpModule::Get().CreateRequest(); r->OnProcessRequestComplete().BindUObject( this, &UMyHttpTask::HandleRequest ); r->SetURL( TEXT( "https://example.com/" ) ); r->SetVerb( TEXT( "POST" ) ); r->SetContentAsString( TEXT( "nyanko" ) ); r->ProcessRequest();
ä½ãééãã¦ããã ãããï¼ãããã¯è¶³ããªãã ãããï¼ä½è¨ã ãããï¼ãã®å®è£ ä¾ã§è½ã¡ãå ´åã®çã㯠Crash Reporter ã§ç¥ããã
Assertion failed: !GetHeader("Content-Type").IsEmpty() || IsURLEncoded(RequestPayload) [File:D:\Build\++UE4+Release-4.19+Compile\Sync\Engine\Source\Runtime\Online\HTTP\Private\Curl\CurlHttp.cpp] [Line: 569]
UE4ã®å®è£
ã®ã¢ãµã¼ã·ã§ã³ã§"殺ããã¦"ãããã¢ãµã¼ã·ã§ã³ã®åé ã® !GetHeader("Content-Type").IsEmpty()
ã§åããããã«ã Content-Type
ãããã¼ãã足ããªããã¨åããããããªäºã§ UE4Editor ãã¨ã¢ãµã¼ã·ã§ã³ã§æ®ºãããã¨ã¯æããªãã£ãã®ã§ãééããã¨ãã«ã¯ããªããããã©ãããä½ããè¸ãã ãã®ã
â¦ãã¨è¦æãããã®ã®ãåå 㯠"ãããªäº" ã ã£ãã
次ã®ããã« Content-Type
ãè¨å®ããå®è£
ã追å ããã¨æå¾
åä½ããããã«ãªãã
r->SetHeader( TEXT( "Content-Type" ), TEXT( "text/plain" ) );
ä»åã®ä¾ã§ã¯ SetContentAsString
ã使ã£ã¦ããã®ã§ Content-Length
ã¯èªåçã«å ãããããã¾ããè足ã¨ãã¦POSTãã©ã¼ã ã®ã¯ã¨ãªã¼ãä½è£ã®å ´åãContent-Type
㯠application/x-www-form-urlencoded
ã¨ããã