-
Notifications
You must be signed in to change notification settings - Fork 63
Expand file tree
/
Copy pathFissionHttpContext.cs
More file actions
44 lines (38 loc) · 1.25 KB
/
FissionHttpContext.cs
File metadata and controls
44 lines (38 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Text.Json;
namespace Fission.DotNet.Common;
public class FissionHttpContext : FissionContext
{
private string _method;
public FissionHttpContext(Stream body, string method, Dictionary<string, object> arguments, Dictionary<string, string> headers, Dictionary<string, string> parameters) : base(body, arguments, headers, parameters)
{
_method = method;
}
public Dictionary<string, string> Headers => _headers;
public string Url
{
get
{
var urlHeader = GetHeaderValue("X-Fission-Full-Url");
if (urlHeader != null)
{
if (urlHeader.Contains("?"))
{
urlHeader = urlHeader.Substring(0, urlHeader.IndexOf("?"));
}
return urlHeader;
}
else
{
return "/";
}
}
}
public string Method => _method;
public string Host => GetHeaderValue("X-Forwarded-Host");
public int Port => _headers.ContainsKey("X-Forwarded-Port") ? Int32.Parse(GetHeaderValue("X-Forwarded-Port")) : 0;
public string UserAgent => GetHeaderValue("User-Agent");
}