Files
TouchSocket/RRQMSocket.Http/Helper/RequestHelper.cs
2021-08-13 21:41:12 +08:00

58 lines
2.1 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//------------------------------------------------------------------------------
// 此代码版权除特别声明或在RRQMCore.XREF命名空间的代码归作者本人若汝棋茗所有
// 源代码使用协议遵循本仓库的开源协议及附加协议若本仓库没有设置则按MIT开源协议授权
// CSDN博客https://blog.csdn.net/qq_40374647
// 哔哩哔哩视频https://space.bilibili.com/94253567
// Gitee源代码仓库https://gitee.com/RRQM_Home
// Github源代码仓库https://github.com/RRQM
// 交流QQ群234762506
// 感谢您的下载和使用
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
namespace RRQMSocket.Http
{
/// <summary>
/// 请求辅助类
/// </summary>
public static class RequestHelper
{
/// <summary>
/// 从Xml格式
/// </summary>
/// <param name="httpRequest"></param>
/// <param name="xmlText"></param>
/// <returns></returns>
public static HttpRequest FromXML(this HttpRequest httpRequest, string xmlText)
{
httpRequest.SetContent(xmlText);
httpRequest.Content_Type = "text/xml";
return httpRequest;
}
/// <summary>
/// 从Json
/// </summary>
/// <param name="httpRequest"></param>
/// <param name="jsonText"></param>
/// <returns></returns>
public static HttpRequest FromJson(this HttpRequest httpRequest, string jsonText)
{
httpRequest.SetContent(jsonText);
httpRequest.Content_Type = "text/json";
return httpRequest;
}
/// <summary>
/// 从文本
/// </summary>
/// <param name="httpRequest"></param>
/// <param name="text"></param>
/// <returns></returns>
public static HttpRequest FromText(this HttpRequest httpRequest, string text)
{
httpRequest.SetContent(text);
httpRequest.Content_Type = "text/plain";
return httpRequest;
}
}
}