Esempio n. 1
0
        /// <summary>
        /// 获取所有请求头
        /// </summary>
        /// <param name="connId"></param>
        /// <returns></returns>
        public List <THeader> GetAllHeaders(IntPtr connId)
        {
            var list = new List <THeader>();

            try
            {
                uint   count  = 0;
                IntPtr arrPtr = IntPtr.Zero;
                HttpSdk.HP_HttpClient_GetAllHeaders(pClient, arrPtr, ref count);
                if (count > 0)
                {
                    var ptrArr = new THeaderForIntPtr[count];
                    arrPtr = Marshal.UnsafeAddrOfPinnedArrayElement(ptrArr, 0);
                    if (HttpSdk.HP_HttpClient_GetAllHeaders(pClient, arrPtr, ref count))
                    {
                        foreach (var item in ptrArr)
                        {
                            list.Add(new THeader()
                            {
                                Name  = Common.PtrToAnsiString(item.Name),
                                Value = Common.PtrToAnsiString(item.Value),
                            });
                        }
                    }
                }
            }
            catch (Exception)
            {
            }

            return(list);
        }