Knetik.KnetikRequest.Send C# (CSharp) Method

Send() public method

public Send ( Action callback ) : void
callback Action
return void
        public void Send( Action<KnetikRequest> callback )
        {
            completedCallback = callback;

            isDone = false;
            state = KnetikRequestState.Waiting;
            if (acceptGzip)
                SetHeader ("Accept-Encoding", "gzip");

            if ( this.cookieJar != null )
            {
                List< KnetikCookie > cookies = this.cookieJar.GetCookies( new KnetikCookieAccessInfo( uri.Host, uri.AbsolutePath ) );
                string cookieString = this.GetHeader( "cookie" );
                for ( int cookieIndex = 0; cookieIndex < cookies.Count; ++cookieIndex )
                {
                    if ( cookieString.Length > 0 && cookieString[ cookieString.Length - 1 ] != ';' )
                    {
                        cookieString += ';';
                    }
                    cookieString += cookies[ cookieIndex ].name + '=' + cookies[ cookieIndex ].value + ';';
                }
                SetHeader( "cookie", cookieString );
            }

            if ( bytes != null && bytes.Length > 0 && GetHeader ("Content-Length") == "" ) {
                SetHeader( "Content-Length", bytes.Length.ToString() );
            }
            /*
            if ( GetHeader( "User-Agent" ) == "" ) {
                SetHeader( "User-Agent", "UnityWeb 1.0 ( Unity " + Application.unityVersion + " ) ( " + SystemInfo.operatingSystem + " )" );
            }
             */
            if ( GetHeader( "Connection" ) == "" ) {
                SetHeader( "Connection", "close" );
            }

            // Basic Authorization
            if (!String.IsNullOrEmpty(uri.UserInfo)) {
                SetHeader("Authorization", "Basic " + System.Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(uri.UserInfo)));
            }

            if (synchronous) {
                GetResponse();
            } else {
                ThreadPool.QueueUserWorkItem (new WaitCallback ( delegate(object t) {
                    GetResponse();
                }));
            }
        }

Same methods

KnetikRequest::Send ( ) : void

Usage Example

        public KnetikApiResponse(KnetikClient client, KnetikRequest req, Action<KnetikApiResponse> callback = null)
        {
            Status = StatusType.Pending;
            Client = client;
            Request = req;
            Callback = callback;

            if (callback == null) {
                req.synchronous = true;
                req.Send();
                CompleteCallback (req);
            } else {
                req.Send(CompleteCallback);
            }
        }