apache 服务器开启PUT的方法

哈喽,大家好,我叫人宅 ,很高兴和大家一起来分享如何让apache服务器如何开启PUT的方法。

我们在搭建自己的独立HTTP服务器,其中apache默认支持GET,POST等操作,但是不支持PUT和DELLTE.这个也是为了安全考虑,如果希望开通PUT功能,直接跳过账号验证,可以参考我下面的方法:


1.先打开如下文件,这里是关于apache服务器的相关配置

2.然后把下面的mod_dav和mode_dav_fs 打开

mod_dav:运行HTTP协议在远程的web访问上创建移动和复制及删除资源和集合的功能;

mode_dav_fs :它可以很好的支持mod_dav模块,并且提供对于服务器文件系统的资源访问;

3.在Directory/目录下启动Dav

4.在Apache 配置目录下创建一个DavLock,这是一个文件锁,记录它的路径;

5.将路径加载到httpd.conf最顶部

6.重启


现在我们来实战一下,看看具体效果如何。

我这边使用了SimpleHTTP插件:

代码如下:

#include "HTTPObjectStorageClient.h"
#include "SimpleHttpManage.h"
#include "RequiredProgramMainCPPInclude.h"
#include "SimpleHTTPType.h"
#if PLATFORM_WINDOWS
#pragma optimize("",off) 
#endif
DEFINE_LOG_CATEGORY_STATIC(LogHTTPObjectStorageClient, Log, All);

IMPLEMENT_APPLICATION(HTTPObjectStorageClient, "HTTPObjectStorageClient");

INT32_MAIN_INT32_ARGC_TCHAR_ARGV()
{
	GEngineLoop.PreInit(ArgC, ArgV);
	UE_LOG(LogHTTPObjectStorageClient, Display, TEXT("Hello World"));

	auto GetParseValue = [](const FString& InKey)->FString
	{
		FString Value;
		if (!FParse::Value(FCommandLine::Get(), *InKey, Value))
		{
			UE_LOG(LogHTTPObjectStorageClient, Error, TEXT("%s was not found value"), *InKey);
		}

		return Value;
	};

	//账户
	FString Bucket = GetParseValue(TEXT("-Bucket="));
	FString PatchVersionLogName = GetParseValue(TEXT("-PatchVersionLogName="));
	FString ServerVersionName = GetParseValue(TEXT("-ServerVersionName="));
	FString VersionLock = GetParseValue(TEXT("-VersionLock="));
	FString Platform = GetParseValue(TEXT("-platform="));
	FString PakLocalPaths = GetParseValue(TEXT("-PakLocalPaths="));

	FSimpleHTTPResponseDelegate Delegate;
	Delegate.AllTasksCompletedDelegate.BindLambda([]()
	{
		
	});
	Delegate.SimpleSingleRequestHeaderReceivedDelegate.BindLambda([](const FSimpleHttpRequest& a, const FString& v, const FString& c)
		{
			if (a.ContentLength > 0)
			{
				UE_LOG(LogHTTPObjectStorageClient, Display, TEXT("%s"),*v);
				UE_LOG(LogHTTPObjectStorageClient, Display, TEXT("%s"),*c);

			}
		});
	FString URL = TEXT("http://192.168.31.137");
	FString LocalAsset = FPaths::ConvertRelativePathToFull( FPaths::ProjectDir() / TEXT("xxx1.zip"));

	SIMPLE_HTTP.PutObjectFromLocal(Delegate, URL/ TEXT("xxx1.zip"), LocalAsset);

	double LastTime = FPlatformTime::Seconds();
	for (;;)
	{
		FPlatformProcess::Sleep(0.03f);
		double Now = FPlatformTime::Seconds();
		float DeltaSenconds = Now - LastTime;
		FSimpleHttpManage::Get()->Tick(DeltaSenconds);

		LastTime = Now;
	}

	FEngineLoop::AppExit();
	return 0;
}

#if PLATFORM_WINDOWS
#pragma optimize("",on) 
#endif

可以看到,成功上传:

发表评论