private void BufferRequestProcessInfo(ApiRequestProcessInfo apiRequestInfo) { if (this._isBufferRequest) { BufferServiceManager.TransportService.Transport(apiRequestInfo); } }
public static void SetRequestProcessInfo(this HttpRequestMessage request, ApiRequestProcessInfo apiRequestInfo) { if (!request.Properties.ContainsKey(IdentityInfo_Context_Key)) { request.Properties.Add(RequestInfo_Context_Key, apiRequestInfo); } else { request.Properties[RequestInfo_Context_Key] = apiRequestInfo; } }
public static ApiRequestProcessInfo GetRequestProcessInfo(this HttpRequestMessage request) { ApiRequestProcessInfo apiRequestInfo = null; object obj; if (request.Properties.TryGetValue(RequestInfo_Context_Key, out obj)) { return((ApiRequestProcessInfo)obj); } return(apiRequestInfo); }
private ApiRequestProcessInfo BuildRequestInfo(System.Web.Http.Controllers.HttpActionContext actionContext) { var request = actionContext.Request; var requestInfo = new ApiRequestProcessInfo(); requestInfo.IdentityInfo = request.GetIdentityInfo(); requestInfo.RequestStartTime = System.DateTime.Now; requestInfo.Lng = request.GetHeaderValue <double>(_lng_key); requestInfo.Lat = request.GetHeaderValue <double>(_lat_key); requestInfo.ClientNetType = request.GetHeaderValue(_client_nettype_key); requestInfo.InterfaceVersion = request.GetHeaderValue(_interface_version_key); requestInfo.ClientVersion = request.GetHeaderValue(_client_version_key); requestInfo.ClientType = request.GetHeaderValue <DevicePlatform>(_client_type_key); requestInfo.ClientWidth = request.GetHeaderValue <int>(_client_width_key); requestInfo.ClientHeight = request.GetHeaderValue <int>(_client_height_key); requestInfo.UserAgent = request.Headers.UserAgent.ToString(); requestInfo.RequestUrl = actionContext.Request.RequestUri.ToString(); // 获取cookie IEnumerable <string> values; if (request.Headers.TryGetValues("Cookie", out values)) { foreach (var item in values) { requestInfo.RequestCookie += item + "~"; } if (requestInfo.RequestCookie.Length > 0) { requestInfo.RequestCookie = requestInfo.RequestCookie.TrimEnd('~'); } } // 获取IP,有从TcpIP层获取的IP和http header获取的IP var ips = request.GetAllIpAddress(); requestInfo.ClientIP = ips.HttpClientIp; requestInfo.ClientIP2 = ips.NginxClientIp; requestInfo.IsHttps = ips.IsHttps; //获取请求方法 requestInfo.HttpMethod = request.Method.Method; requestInfo.RequestArguments = actionContext.ActionArguments; return(requestInfo); }