public HomeController(IPostData postData, IGreeter greeter, UserManager <User> userManager, ICommentData commentData) { _postData = postData; _greeter = greeter; _userManager = userManager; _commentData = commentData; }
/// <summary> /// 组装请求参数 /// </summary> /// <param name="data"></param> /// <param name="time">服务器时间</param> /// <param name="userId">用户id</param> /// <param name="param">参数组装格式</param> /// <returns></returns> string PostParamGroup(IPostData data, long time, string userId, string param) { string urlValue = ""; int count = (int)Mathf.Min((float)requestGroupMax, (float)groupData.Count); for (int i = 0; i < count; i += 1) { ArrayList tmpData = groupData.Dequeue() as ArrayList; //拉取一个 List <object> args = tmpData[1] as List <object>; string commandId = tmpData[0] as string; urlValue += ParamtersPack(commandId, args, time, userId, param); //参数组装 if (!data.commandId.Contains(commandId)) { data.commandId.Add(commandId); data.resultBack.Add((HttpNetResultDelegate)tmpData[2]); } if (i != count - 1) { urlValue += ","; } } return(urlValue); }
/// <summary> /// 触发回调委托 /// </summary> /// <param name="data"></param> /// <param name="res"></param> /// <param name="result"></param> /// <param name="errMsg"></param> /// <param name="isError"></param> void TriggerResponse(IPostData data, int res, string result, string errMsg, bool isError = false) { int count = data.commandId.Count; string commandId; HttpNetResultDelegate resultBack; for (int i = 0; i < count; i += 1) { commandId = data.commandId[i]; if (onResponseDict.ContainsKey(commandId)) { onResponseDict[commandId](commandId, res, result); } if (!isError) { resultBack = data.resultBack[i]; if (resultBack != null) { resultBack(commandId, res, result); } } } if (serverErrorResponse != null && res != NetworkDataParser.RESPONSE_CODE_RESULT_SUCCESS) { Debug.LogWarning("HttpNetManager::TriggerResponse Error : commandId:[" + data.ToString() + "]error:" + errMsg); serverErrorResponse(errMsg, res, result); } }
public IPromise Post(IPostData _data) { return(Promise.Sequence( () => runCommand(new LoginFBCommand(eventProvider)), () => runCommand(new PostToFBCommand(eventProvider).SetData(_data)) )); }
public IndexModel(IPostData postData, IConfiguration config) { _postData = postData; if (!int.TryParse(config["PageSize"], out _pageSize)) { _pageSize = DefaultPageSize; } }
public HomeController(IPostData postData, ICommentData commentData, IContactMessageData contactMessageData, IAdministratorData administratorData) { _postData = postData; _commentData = commentData; _contactMessageData = contactMessageData; _administratorData = administratorData; }
} // GET/POST: ToUri /// <summary>Create a new GET or POST request</summary> /// <param name="uri">URI to retrieve</param> /// <param name="postData">null = GET, non-null = POST</param> public ScrapeRequest(Uri uri, IPostData postData, params Action <RequestSettings>[] adjustSettings) { if (uri == null) { throw new ArgumentNullException(nameof(uri)); } this.Uri = uri; this.PostData = postData; this.AdjustSettings = adjustSettings; }
/// <summary> /// 请求http /// </summary> /// <param name="data"></param> /// <returns></returns> IEnumerator PostAsync(IPostData data, bool isReset = false) { if (netTimer.isTimeOut) { yield break; //超时退出请求 } if (!isReset) { netTimer.StartTime(); //计时开始 } string url = data.url; Debug.Log(">>:" + url); WWW www = new WWW(url); yield return(www); // yield break; //测试超时 Debug.Log("<< [" + data.ToString() + "]:" + www.text); netTimer.StopTime(); //计时停止 if (netTimer.isTimeOut) { yield break; //超时退出请求,防止超时了还回来数据 } string result = www.text; int res = -1; string errMsg = ""; try { if (netParser == null) { netParser = new NetworkDataParser(); } res = netParser.ParseData(result, out errMsg); serverTime = netParser.serverTime; } catch (Exception e) { Debug.LogWarning("HttpNetManager::PostAsync Error : commandId:[" + data.ToString() + "]error:" + e.Message + " Trace [" + e.StackTrace + "]"); TriggerResponse(data, res, result, errMsg, true); yield break; } TriggerResponse(data, res, result, errMsg); if (res == NetworkDataParser.RESPONSE_CODE_RESULT_SUCCESS && queueDataGroup.NextSendRequest) { //进入下一组 SendRequest(); } }
public void AddPostData(IPostData data) { if (data == null) { return; } if (PostDataCollection == null) { PostDataCollection = new List <IPostData>(); } PostDataCollection.Add(data); }
/// <summary> /// Add a new <see cref="IPostDataElement"/> that represents the specified file /// </summary> /// <param name="postData">post data instance</param> /// <param name="fileName">file name</param> public static void AddFile(this IPostData postData, string fileName) { if (string.IsNullOrEmpty(fileName)) { throw new ArgumentNullException("fileName"); } var element = postData.CreatePostDataElement(); element.File = fileName; postData.AddElement(element); }
/// <summary> /// Add a new <see cref="IPostDataElement"/> that represents the key and value /// </summary> /// <param name="postData">Post Data</param> /// <param name="bytes">byte array that represents the post data</param> public static void AddData(this IPostData postData, byte[] bytes) { if (bytes == null) { throw new ArgumentNullException("bytes"); } var element = postData.CreatePostDataElement(); element.Bytes = bytes; postData.AddElement(element); }
void ResetSendRequest(bool isReset = true) { IPostData postData = queueDataGroup.currentPostData; if (postData == null) { Debug.LogWarning("HttpNetManager::ResetSend :Error:No data can be sent!"); return; } Debug.LogWarning("HttpNetManager::ResetSend :reset send commandId:[" + postData.ToString() + "]" + isReset); StartCoroutine(PostAsync(postData, isReset)); }
/// <summary> /// 发送请求 /// </summary> void SendRequest() { if (!queueDataGroup.isCanSend) { return; //没有请求 } IPostData postData = queueDataGroup.GroupPostDataPack(serverTime); if (postData == null) { return; } StartCoroutine(PostAsync(postData)); }
HttpWebRequest BuildHttpWebRequest(ScrapeRequest request) { // build next request HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(request.Uri); httpRequest.AllowAutoRedirect = this.UseFrameworkRedirect; // we can do this manually httpRequest.CookieContainer = this._cookieJar; httpRequest.CachePolicy = this.CachePolicy; RequestSettings settings = ApplyCustomSettingsToDefaultSettings(request); httpRequest.Accept = settings.Accept; httpRequest.UserAgent = settings.UserAgent; httpRequest.ProtocolVersion = settings.ProtocolVersion; httpRequest.KeepAlive = settings.KeepAlive; httpRequest.Timeout = settings.Timeout; httpRequest.Credentials = settings.Credentials; httpRequest.Referer = settings.Referrer ?? this._lastPage; foreach (var pair in settings.Headers) { httpRequest.Headers[pair.Key] = pair.Value; } // httpRequest.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip; // request.Headers["Accept-Encoding"] = "gzip,deflate"; // don't set this directly without using the above line(I guess) // convert it to a post message if needed IPostData postData = request.PostData; if (postData != null) { byte[] postBytes = postData.PostBytes; // set request headers as appropriat httpRequest.Method = "POST"; httpRequest.ContentLength = postBytes.Length; httpRequest.ContentType = postData.ContentType; // feed post data into the request using (System.IO.Stream requestStream = httpRequest.GetRequestStream()) { requestStream.Write(postBytes, 0, postBytes.Length); } } return(httpRequest); }
/// <summary> /// Add a new <see cref="IPostDataElement"/> that represents the key and value /// The data is encoded using /// </summary> /// <param name="postData">Post Data</param> /// <param name="data">Data to be encoded for the post data element</param> /// <param name="encoding">Specified Encoding. If null then <see cref="Encoding.Default"/> will be used</param> public static void AddData(this IPostData postData, string data, Encoding encoding = null) { if (string.IsNullOrEmpty(data)) { throw new ArgumentNullException("data"); } if (encoding == null) { encoding = Encoding.Default; } var element = postData.CreatePostDataElement(); element.Bytes = encoding.GetBytes(data); postData.AddElement(element); }
public CommentController(IPostData pd) { this.pd = pd; }
public HomeController(IPostData addUserDetails, AppDbContext db) { this.pd = addUserDetails; this.db = db; }
public PostToFBCommand SetData(IPostData _data) { postData = _data; return(this); }
public EditModel(IPostData postData) { _postData = postData; }
public PostsController(IPostData postData, IMapper mapper) { _postData = postData; _mapper = mapper; }
/// <summary> /// 【setup2】提取cookie /// </summary> /// <param name="browserControl"></param> /// <param name="browser"></param> /// <param name="frame"></param> /// <param name="request"></param> /// <param name="response"></param> /// <param name="status"></param> /// <param name="receivedContentLength"></param> public override void OnResourceLoadComplete(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response, UrlRequestStatus status, long receivedContentLength) { if (response.StatusCode != 200) { return; } var url = new Uri(request.Url); var extension = url.ToString().ToLower(); if (SystemSetting.SystemSettingDict["OpenDebug"] == "true") {//开启debug模式 extension.WriteLog(ELogType.Account, true); //输入写入到请求日志 IPostData data = request.PostData; if (data != null) { //请求内容被转换为了文件流 //输出有请求参数的URL StringBuilder requestHead = new StringBuilder(); requestHead.AppendLine(string.Format("url hava request param-> {0} ", extension)); foreach (var item in request.Headers.AllKeys) { requestHead.Append(string.Format("{0} : {1};", item, request.Headers[item])); } requestHead.ToString().WriteLog(ELogType.HttpRequest, true); } } //if (!extension.Contains(SystemConfig.CookieDomain)) //{ // return; //} if ((!SystemConfig.AnywhereGetCookie && extension != SystemConfig.InitCookeKey)) { return; } //这是请求响应头 ICookieManager cookie = Cef.GetGlobalCookieManager(); if (SystemConfig.AnywhereGetCookie) {//无限制提取cookie cookie.VisitAllCookies(new CookieVisitor()); } else { foreach (var urlFrom in SystemConfig.CookieFrom) { cookie.VisitUrlCookies(urlFrom, false, new CookieVisitor()); } } if (extension == SystemConfig.TockenAfterUrl) {//是否已经获取到了tocken ExistsTocken = true; } if (CookieHandle.GetCoreCookie(CookieVisitor.CookieDict)) { //从其他应用中获取到了cookie ExistsTocken = true; } if (ExistsTocken) {//提取到了完整的cookie StringBuilder cook = new StringBuilder(); cook.AppendLine(CookieVisitor.OutputCookie(CookieVisitor.CookieDict).ToString()); cook.ToString().WriteLog(ELogType.SessionOrCookieLog, true); //CookieContainer GetCookieResponse(CookieVisitor.CookieDict); } if (_requestHeandler != null) { _requestHeandler.OnResourceLoadComplete(browserControl, browser, frame, request, response, status, receivedContentLength); } if (SystemConfig.DownloadResource) { DownloadService.DownloadResource(extension, responseDictionary, request, response); } return; }
public UsersController(IPostData postData) { _postData = postData; }
public PostController(IPostData pd) { this.pd = pd; //Users = pd.GetUserByNameAndEmail(userDetails.Name, userDetails.Email).ToList(); //Id = Users[0].UserId; }
public SqlCommentData(MyBlogDbContext context, IPostData postData) { _context = context; _postData = postData; }
/// <summary> /// 添加Post表单数据 /// </summary> /// <param name="data"></param> public HttpHelper AddPostData(IPostData data) { this._requestData.AddPostData(data); return(this); }
/// <summary> /// 请求http /// </summary> /// <param name="data"></param> /// <returns></returns> IEnumerator PostAsync(IPostData data, bool isReset = false) { if (netTimer.isTimeOut) yield break; //超时退出请求 if (!isReset) netTimer.StartTime(); //计时开始 string url = data.url; Debug.Log(">>:" + url); WWW www = new WWW(url); yield return www; // yield break; //测试超时 Debug.Log("<< [" + data.ToString() + "]:" + www.text); netTimer.StopTime(); //计时停止 if (netTimer.isTimeOut) yield break; //超时退出请求,防止超时了还回来数据 string result = www.text; int res = -1; string errMsg = ""; try { if (netParser == null) { netParser = new NetworkDataParser(); } res = netParser.ParseData(result, out errMsg); serverTime = netParser.serverTime; } catch (Exception e) { Debug.LogWarning("HttpNetManager::PostAsync Error : commandId:[" + data.ToString() + "]error:" + e.Message + " Trace [" + e.StackTrace + "]"); TriggerResponse(data, res, result, errMsg, true); yield break; } TriggerResponse(data, res, result, errMsg); if (res == NetworkDataParser.RESPONSE_CODE_RESULT_SUCCESS && queueDataGroup.NextSendRequest) { //进入下一组 SendRequest(); } }
public DeleteModel(IPostData postData) { this.postData = postData; }
/// <summary> /// 组装请求参数 /// </summary> /// <param name="data"></param> /// <param name="time">服务器时间</param> /// <param name="userId">用户id</param> /// <param name="param">参数组装格式</param> /// <returns></returns> string PostParamGroup(IPostData data, long time, string userId, string param) { string urlValue = ""; int count = (int)Mathf.Min((float)requestGroupMax, (float)groupData.Count); for (int i = 0; i < count; i += 1) { ArrayList tmpData = groupData.Dequeue() as ArrayList; //拉取一个 List<object> args = tmpData[1] as List<object>; string commandId = tmpData[0] as string; urlValue += ParamtersPack(commandId, args, time, userId, param); //参数组装 if (!data.commandId.Contains(commandId)) { data.commandId.Add(commandId); data.resultBack.Add((HttpNetResultDelegate)tmpData[2]); } if (i != count - 1) { urlValue += ","; } } return urlValue; }
public DetailsModel(IPostData postData) { _postData = postData; }
public AddUserModel(IPostData postdata) { this.postdata = postdata; }
public ShowPostModel(IPostData postData) { _postData = postData; }
public HomeModel(IPostData postdata) { this.postdata = postdata; }