Commit db9e05d0 authored by Jehonathan's avatar Jehonathan Committed by GitHub

Merge pull request #145 from nordinrahman/patchMethodSupport

Add support for request with PATCH method
parents b66fe657 545f5b66
......@@ -79,7 +79,8 @@ namespace Titanium.Web.Proxy.Examples.Basic
////read request headers
var requestHeaders = e.WebSession.Request.RequestHeaders;
if ((e.WebSession.Request.Method == "POST" || e.WebSession.Request.Method == "PUT"))
var method = e.WebSession.Request.Method.ToUpper();
if ((method == "POST" || method == "PUT" || method == "PATCH"))
{
//Get/Set request body bytes
byte[] bodyBytes = await e.GetRequestBody();
......
......@@ -107,8 +107,9 @@ Sample request and response event handlers
////read request headers
var requestHeaders = e.WebSession.Request.RequestHeaders;
if ((e.WebSession.Request.Method == "POST" || e.WebSession.Request.Method == "PUT"))
var method = e.WebSession.Request.Method.ToUpper();
if ((method == "POST" || method == "PUT" || method == "PATCH"))
{
//Get/Set request body bytes
byte[] bodyBytes = await e.GetRequestBody();
......
......@@ -81,10 +81,11 @@ namespace Titanium.Web.Proxy.EventArguments
private async Task ReadRequestBody()
{
//GET request don't have a request body to read
if ((WebSession.Request.Method.ToUpper() != "POST" && WebSession.Request.Method.ToUpper() != "PUT"))
var method = WebSession.Request.Method.ToUpper();
if ((method != "POST" && method != "PUT" && method != "PATCH"))
{
throw new BodyNotFoundException("Request don't have a body." +
"Please verify that this request is a Http POST/PUT and request " +
throw new BodyNotFoundException("Request don't have a body. " +
"Please verify that this request is a Http POST/PUT/PATCH and request " +
"content length is greater than zero before accessing the body.");
}
......
......@@ -312,8 +312,9 @@ namespace Titanium.Web.Proxy
{
if (!args.WebSession.Request.ExpectationFailed)
{
//If its a post/put request, then read the client html body and send it to server
if (args.WebSession.Request.Method.ToUpper() == "POST" || args.WebSession.Request.Method.ToUpper() == "PUT")
//If its a post/put/patch request, then read the client html body and send it to server
var method = args.WebSession.Request.Method.ToUpper();
if (method == "POST" || method == "PUT" || method == "PATCH")
{
await SendClientRequestBody(args);
}
......@@ -570,7 +571,7 @@ namespace Titanium.Web.Proxy
}
/// <summary>
/// This is called when the request is PUT/POST to read the body
/// This is called when the request is PUT/POST/PATCH to read the body
/// </summary>
/// <param name="args"></param>
/// <returns></returns>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment