Beispiel #1
0
    public void AsyUpLoad(string url, byte[] bytes, string userId)
    {
        strBoundary   = "----------" + DateTime.Now.Ticks.ToString("x");
        boundaryBytes = Encoding.ASCII.GetBytes("\r\n--" + strBoundary + "\r\n");

        var webState = new WebState();

        try
        {
            var strPostHeader   = string.Format(headerTemplate, strBoundary, "file", "temp");
            var postHeaderBytes = Encoding.UTF8.GetBytes(strPostHeader);

            webState.WriteMemory(bytes, bytes.Length);
            webState.CreateRequest(url + "?file_path=" + userId);
            webState.SetRequestInfo("POST", false, 300000, "multipart/form-data; boundary=" + strBoundary, true, webState.GetMemorySize() + postHeaderBytes.Length + boundaryBytes.Length);

            m_size    = webState.GetMemorySize();
            m_curSize = 0;

            webState.SetStream(false);
            webState.SetBuffer(postHeaderBytes);
            webState.StreamBeginWrite(postHeaderBytes.Length, UpLoadWriteDataCallback);
        }
        catch (WebException e)
        {
            HttpHelperErr(string.Format(UpLoadErrFormat, webState.GetRequestUrl(), e.Message, e.Status), data);
        }
    }
Beispiel #2
0
 private ClientUpgrade( string domainID )
 {
     WebState ws = new WebState(domainID, domainID);
        hostAddress = DomainProvider.ResolveLocation( domainID ).ToString();
        service = new ClientUpdate();
        service.Url = hostAddress + "/ClientUpdate.asmx";
        ws.InitializeWebClient(service, domainID);
 }
Beispiel #3
0
        /// <summary>
        /// Initializes a new instance of the object.
        /// </summary>
        /// <param name="domainID">Identifier of the domain that the user belongs to.</param>
        private ClientUpgrade(string domainID)
        {
            // Set the web state when authentication is really required...
            WebState ws = new WebState(domainID, domainID);

            // Get the address of the host service.
            hostAddress = DomainProvider.ResolveLocation(domainID).ToString();
            // Setup the url to the server.
            service     = new ClientUpdate();
            service.Url = hostAddress + "/ClientUpdate.asmx";
            ws.InitializeWebClient(service, domainID);
        }
Beispiel #4
0
 public void AsyDownLoad(string url, string saveFilePath)
 {
     try
     {
         WebState webState = new WebState(saveFilePath);
         webState.CreateRequest(url);
         webState.BeginGetResponse(ResponseCallback);
     }
     catch (WebException e)
     {
         HttpHelperErr(string.Format(DownLoadErrFormat, url, e.Message, e.Status), data);
     }
 }
Beispiel #5
0
        /// <summary>
        /// Used by the client to autenticate using Private Key Authentication.
        /// </summary>
        /// <param name="domainId"></param>
        /// <param name="memberId"></param>
        /// <param name="baseUrl"></param>
        /// <returns></returns>
        public static bool AuthenticateWithPPK(string domainId, string memberId, string baseUrl)
        {
            try
            {
                Store    store    = Store.GetStore();
                Domain   domain   = store.GetDomain(domainId);
                Member   member   = domain.GetMemberByID(memberId);
                WebState webState = new WebState(domainId);
                // Get the challenge and sign it with the Private Key to use as a one time password.
                string         url     = baseUrl + "/Login.ashx?" + NonceKey + "=Get";
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                webState.InitializeWebRequest(request, domain.ID);
                request.ContentType = "application/octet-stream";
                request.Method      = "GET";
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                request.CookieContainer.Add(response.Cookies);

                if (response.StatusCode != HttpStatusCode.OK)
                {
                    CookieCollection cc = request.CookieContainer.GetCookies(new Uri(url));
                    foreach (Cookie cookie in cc)
                    {
                        cookie.Expired = true;
                    }
                    return(false);
                }

                string nonce = response.Headers.Get(NonceKey);
                if (nonce != null)
                {
                    byte[] bChallenge = Nonce.GetBytes(nonce);
                    byte[] signed     = store.CurrentUser.GetDomainCredential(domain.ID).SignData(bChallenge, new SHA1CryptoServiceProvider());
                    // Now authenticate using signed data
                    url     = baseUrl + "/Login.ashx?" + PpkAuthKey + "=" + member.UserID;
                    request = (HttpWebRequest)WebRequest.Create(url);
                    webState.InitializeWebRequest(request, domain.ID);
                    request.ContentType = "application/octet-stream";
                    request.Method      = "POST";
                    request.Headers.Add(Simias.Security.Web.AuthenticationService.Login.DomainIDHeader, domain.ID);
                    Stream rStream = request.GetRequestStream();
                    rStream.Write(signed, 0, signed.Length);
                    rStream.Close();
                    response = (HttpWebResponse)request.GetResponse();
                }
            }
            catch { return(false); }
            return(true);
        }
 /// <summary>
 /// 初始化天气
 /// </summary>
 private void InitWeather()
 {
     //如果网络已连接,则获取最新的天气,否则读取本地天气
     if (WebState.isConneted())
     {
         //获取天气
         WeatherStructure mWeather = WebWeather.getWeatherByCode(WebWeather.getCodeByIP());
         SetWeather(mWeather);
         //更新本地数据
         File.Delete(Config + "\\Weather.xml");
         XmlDB mDB = XmlDBFactory.CreatXmlDB("Weather", Config + "\\Weather.xml", 1);
         mDB.Insert(mWeather);
         mDB.Commit();
     }
     else
     {
         XmlDB            mDB      = XmlDBFactory.LoadXmlDB(Config + "\\Weather.xml");
         List <object>    mObjects = mDB.ReadByObject(new WeatherStructure());
         WeatherStructure mWeather = (WeatherStructure)mObjects[0];
         SetWeather(mWeather);
     }
 }
Beispiel #7
0
        /// <summary>
        /// Handle when delivered
        /// </summary>
        /// <param name="poBox">POBox reference</param>
        /// <param name="subscription">subscription </param>
        /// <returns>True if successfull, else false</returns>
        private bool DoDelivered(POBox poBox, Subscription subscription)
        {
            bool         result    = false;
            POBoxService poService = new POBoxService();

            log.Debug("  calling the PO Box server to get subscription state");
            log.Debug("  domainID: " + subscription.DomainID);
            log.Debug("  fromID:   " + subscription.FromIdentity);
            log.Debug("  SubID:    " + subscription.MessageID);

            // Resolve the PO Box location for the inviter
            Uri poUri = DomainProvider.ResolvePOBoxLocation(subscription.DomainID, subscription.FromIdentity);

            if (poUri != null)
            {
                poService.Url = poUri.ToString() + poServiceLabel;
                log.Debug("  connecting to the Post Office Service : " + poService.Url);
            }
            else
            {
                log.Debug("  Could not resolve the PO Box location for: " + subscription.FromIdentity);
                return(result);
            }

            try
            {
                WebState webState =
                    new WebState(
                        subscription.DomainID,
                        subscription.SubscriptionCollectionID,
                        subscription.ToIdentity);

                webState.InitializeWebClient(poService, subscription.DomainID);
            }
            catch (NeedCredentialsException)
            {
                log.Debug("  no credentials - back to sleep");
                return(result);
            }

            try
            {
                SubscriptionInformation subInfo =
                    poService.GetSubscriptionInfo(
                        subscription.DomainID,
                        subscription.FromIdentity,
                        subscription.MessageID,
                        subscription.SubscriptionCollectionID);

                switch (subInfo.Status)
                {
                case POBoxStatus.Success:
                {
                    log.Debug("  subInfo.FromName: " + subInfo.FromName);
                    log.Debug("  subInfo.ToName: " + subInfo.ToName);
                    log.Debug("  subInfo.State: " + subInfo.State.ToString());
                    log.Debug("  subInfo.Disposition: " + subInfo.Disposition.ToString());

                    if (subInfo.Disposition == ( int )SubscriptionDispositions.Accepted)
                    {
                        log.Debug("  creating collection...");

                        // Check to make sure the collection proxy doesn't already exist.
                        if (poBox.StoreReference.GetCollectionByID(subscription.SubscriptionCollectionID) == null)
                        {
                            SubscriptionDetails details = new SubscriptionDetails();
                            details.DirNodeID   = subInfo.DirNodeID;
                            details.DirNodeName = subInfo.DirNodeName;

                            subscription.SubscriptionRights = (Access.Rights)subInfo.AccessRights;
                            subscription.AddDetails(details);
                            poBox.Commit(subscription);

                            // create slave stub
                            subscription.ToMemberNodeID = subInfo.ToNodeID;
                            subscription.CreateSlave(poBox.StoreReference);
                        }

                        // acknowledge the message which removes the originator's subscription.
                        SubscriptionMsg subMsg   = subscription.GenerateSubscriptionMessage();
                        POBoxStatus     wsStatus = poService.AckSubscription(subMsg);
                        if ((wsStatus == POBoxStatus.Success) ||
                            (wsStatus == POBoxStatus.AlreadyAccepted))
                        {
                            // done with the subscription - move to local subscription to the ready state
                            log.Debug("  moving subscription to ready state.");
                            subscription.SubscriptionState = SubscriptionStates.Ready;
                            poBox.Commit(subscription);
                            result = true;
                        }
                        else
                        {
                            log.Debug("  failed acknowledging a subscription");
                            log.Debug("  status = {0}", wsStatus.ToString());
                            log.Debug("  deleting the local subscription");

                            poBox.Commit(poBox.Delete(subscription));
                            result = true;
                        }
                    }
                    break;
                }

                case POBoxStatus.AlreadyAccepted:
                {
                    log.Debug("  the subscription has already been accepted by another client.");
                    result = CreateCollectionProxy(poBox, subscription);
                    break;
                }

                case POBoxStatus.InvalidState:
                {
                    log.Debug("  invalid state");
                    break;
                }

                default:
                {
                    log.Debug("  server error = {0}. Deleting subscription.", subInfo.Status.ToString());
                    poBox.Commit(poBox.Delete(subscription));
                    result = true;
                    break;
                }
                }
            }
            catch (Exception e)
            {
                log.Error("  DoDelivered failed with an exception");
                log.Error(e.Message);
                log.Error(e.StackTrace);
            }

            return(result);
        }
Beispiel #8
0
        /// <summary>
        /// Do Replied for the invitation
        /// </summary>
        /// <param name="poBox">POBox from which reply will go </param>
        /// <param name="subscription">Subscription</param>
        /// <returns>True if successfull else false</returns>
        private bool DoReplied(POBox poBox, Subscription subscription)
        {
            log.Debug("DoReplied");
            log.Debug("  calling the PO Box server to accept/reject subscription");
            log.Debug("  domainID: " + subscription.DomainID);
            log.Debug("  fromID:   " + subscription.FromIdentity);
            log.Debug("  toID:     " + subscription.ToIdentity);
            log.Debug("  SubID:    " + subscription.MessageID);

            bool         result    = false;
            POBoxService poService = new POBoxService();
            POBoxStatus  wsStatus  = POBoxStatus.UnknownError;

            // Resolve the PO Box location for the inviter
            Uri poUri = DomainProvider.ResolvePOBoxLocation(subscription.DomainID, subscription.FromIdentity);

            if (poUri != null)
            {
                poService.Url = poUri.ToString() + poServiceLabel;
                log.Debug("  connecting to the Post Office Service : " + poService.Url);
            }
            else
            {
                log.Debug("  could not resolve the PO Box location for: " + subscription.FromIdentity);
                return(result);
            }

            try
            {
                WebState webState =
                    new WebState(
                        subscription.DomainID,
                        subscription.SubscriptionCollectionID,
                        subscription.ToIdentity);

                webState.InitializeWebClient(poService, subscription.DomainID);
            }
            catch (NeedCredentialsException)
            {
                log.Debug("  no credentials - back to sleep");
                return(result);
            }

            // Add a new member to the domain if one doesn't exist already.  This is needed
            // for Workgroup Domains.  If the user doesn't exist, the upcoming call to
            // ResolvePOBoxLocation will fail.
            Domain domain = Store.GetStore().GetDomain(subscription.DomainID);

            if (domain.ConfigType == Domain.ConfigurationType.Workgroup)
            {
                Member member = domain.GetMemberByName(subscription.FromName);
                if (member == null)
                {
                    log.Debug("  added workgroup member {0}", subscription.FromName);
                    member = new Member(subscription.FromName, subscription.FromIdentity, subscription.SubscriptionRights);
                    domain.Commit(member);
                }
            }

            try
            {
                if (subscription.SubscriptionDisposition == SubscriptionDispositions.Accepted)
                {
                    log.Debug("  disposition is accepted!");

                    SubscriptionMsg subMsg = subscription.GenerateSubscriptionMessage();
                    wsStatus = poService.AcceptedSubscription(subMsg);
                    switch (wsStatus)
                    {
                    case POBoxStatus.Success:
                    {
                        log.Debug("  successfully accepted subscription.");
                        subscription.SubscriptionState = SubscriptionStates.Delivered;
                        poBox.Commit(subscription);
                        break;
                    }

                    case POBoxStatus.NotPosted:
                    {
                        log.Debug("  waiting for subscription to be posted.");
                        break;
                    }

                    case POBoxStatus.AlreadyAccepted:
                    {
                        log.Debug("  subscription already accepted from a different client.");
                        result = CreateCollectionProxy(poBox, subscription);
                        break;
                    }

                    case POBoxStatus.AlreadyDeclined:
                    case POBoxStatus.UnknownCollection:
                    case POBoxStatus.UnknownSubscription:
                    case POBoxStatus.UnknownPOBox:
                    case POBoxStatus.UnknownIdentity:
                    {
                        log.Debug("  failed accepting a subscription");
                        log.Debug("  status = {0}", wsStatus.ToString());
                        log.Debug("  deleting the local subscription");

                        // Delete the subscription and return true so the thread
                        // controlling the subscription will die off.
                        poBox.Commit(poBox.Delete(subscription));
                        result = true;
                        break;
                    }

                    default:
                    {
                        log.Debug("  failed Accepting a subscription.  Status: " + wsStatus.ToString());
                        break;
                    }
                    }
                }
                else if (subscription.SubscriptionDisposition == SubscriptionDispositions.Declined)
                {
                    log.Debug("  disposition is declined");

                    SubscriptionMsg subMsg = subscription.GenerateSubscriptionMessage();
                    wsStatus = poService.DeclinedSubscription(subMsg);
                    switch (wsStatus)
                    {
                    case POBoxStatus.Success:
                    {
                        // This subscription is done!
                        log.Debug("  successfully declined subscription {0}", subscription.ID);
                        result = true;
                        break;
                    }

                    case POBoxStatus.AlreadyAccepted:
                    {
                        log.Debug("  subscription already accepted from a different client.");

                        // If the collection has already been accepted on another client, we cannot
                        // automatically accept it here because we don't know where to root the
                        // the collection in the file system.
                        result = true;
                        break;
                    }

                    case POBoxStatus.AlreadyDeclined:
                    case POBoxStatus.UnknownIdentity:
                    case POBoxStatus.UnknownCollection:
                    case POBoxStatus.UnknownPOBox:
                    {
                        log.Debug("  failed declining a subscription");
                        log.Debug("  status = {0}", wsStatus.ToString());
                        log.Debug("  deleting the local subscription");

                        // Delete the subscription and return true so the thread
                        // controlling the subscription will die off.
                        poBox.Commit(poBox.Delete(subscription));
                        result = true;
                        break;
                    }

                    default:
                    {
                        log.Debug("  failed declining a subscription.  Status: " + wsStatus.ToString());
                        break;
                    }
                    }
                }
            }
            catch (Exception e)
            {
                log.Error("  DoReplied failed updating originator's PO box");
                log.Error(e.Message);
                log.Error(e.StackTrace);
            }

            return(result);
        }
Beispiel #9
0
        /// <summary>
        /// Invite the subscription to POBox
        /// </summary>
        /// <param name="poBox">POBox to which subscription to be added</param>
        /// <param name="subscription">Subscription to be invited to POBox</param>
        /// <returns>True if successfull else false</returns>
        private bool DoInvited(POBox poBox, Subscription subscription)
        {
            bool  result = false;
            Store store  = Store.GetStore();

            log.Debug("SubscriptionThread::DoInvited called");
            POBoxService poService = new POBoxService();

            // Resolve the PO Box location for the invitee
            Uri poUri = DomainProvider.ResolvePOBoxLocation(subscription.DomainID, subscription.ToIdentity);

            if (poUri != null)
            {
                poService.Url = poUri.ToString() + poServiceLabel;
                log.Debug("Calling POService::Invite at: " + poService.Url);
            }
            else
            {
                log.Error("  Could not resolve the PO Box location for: " + subscription.FromIdentity);
                return(result);
            }

            //
            // If the Domain Type is "ClientServer" credentials are needed for
            // posting an invitation.  In workgroup, credentials aren't needed.
            //

            Domain domain = store.GetDomain(subscription.DomainID);

            if (domain.ConfigType == Simias.Storage.Domain.ConfigurationType.ClientServer)
            {
                try
                {
                    WebState webState = new WebState(subscription.DomainID, subscription.FromIdentity);
                    webState.InitializeWebClient(poService, domain.ID);
                }
                catch (NeedCredentialsException)
                {
                    log.Debug("  no credentials - back to sleep");
                    return(result);
                }
            }

            //
            // Make sure the shared collection has sync'd to the server before inviting
            //

            Collection cSharedCollection = store.GetCollectionByID(subscription.SubscriptionCollectionID);

            if (cSharedCollection == null)
            {
                return(result);
            }

            if (cSharedCollection.Role == SyncRoles.Slave && cSharedCollection.MasterIncarnation == 0)
            {
                log.Debug(
                    "Failed POBoxService::Invite - collection: {0} hasn't sync'd to the server yet",
                    subscription.SubscriptionCollectionID);

                return(result);
            }

            //
            // Make sure the subscription node has sync'd up to the server as well
            //

            if (poBox.Role == SyncRoles.Slave)
            {
                Node cNode = poBox.Refresh(subscription);
                if (cNode.MasterIncarnation == 0)
                {
                    log.Debug(
                        "Failed POBoxService::Invite - inviter's subscription {0} hasn't sync'd to the server yet",
                        subscription.MessageID);

                    return(result);
                }
            }

            // Remove location of the POBox service
            log.Debug("Connecting to the Post Office Service : " + poService.Url);

            try
            {
                // Set the remote state to received.
                // And post the subscription to the server.
                Simias.Storage.Member me = poBox.GetCurrentMember();
                subscription.FromIdentity = me.UserID;
                subscription.FromName     = me.Name;

                // Make sure that this user has sufficient rights to send this invitation.
                Simias.Storage.Member me2 = cSharedCollection.GetMemberByID(me.UserID);
                if ((me2 == null) || (me2.Rights != Access.Rights.Admin))
                {
                    // The user did not have sufficient rights to send this invitation.
                    // Delete the subscription and don't try to send it anymore.
                    log.Info("User {0} did not have sufficient rights to share collection {1}", me.Name, cSharedCollection.Name);
                    poBox.Commit(poBox.Delete(subscription));
                    return(true);
                }

                POBoxStatus status = poService.Invite(subscription.GenerateSubscriptionMessage());
                if (status == POBoxStatus.Success)
                {
                    log.Debug("Successfully invited {0} to collection {1}.", subscription.FromName, subscription.SubscriptionCollectionName);
                    subscription.SubscriptionState = SubscriptionStates.Posted;
                    poBox.Commit(subscription);
                    result = true;
                }
                else if (status == POBoxStatus.InvalidAccessRights)
                {
                    // The user did not have sufficient rights to send this invitation.
                    // Delete the subscription and don't try to send it anymore.
                    log.Info("User {0} did not have sufficient rights to share collection {1}", me.Name, cSharedCollection.Name);
                    poBox.Commit(poBox.Delete(subscription));
                    result = true;
                }
                else if (status == POBoxStatus.UnknownIdentity)
                {
                    // The invited user no longer exists on the server roster
                    // possibly due to scoping changes by the administrator
                    log.Info("User {0} does not exist in the server domain", me.Name);
                    poBox.Commit(poBox.Delete(subscription));
                    result = true;
                }
                else
                {
                    log.Debug("Failed the remote invite call -  Status: " + status.ToString());
                }
            }
            catch
            {
                log.Debug("Failed POBoxService::Invite - target: " + poService.Url);
            }

            return(result);
        }
Beispiel #10
0
 public Simias.Authentication.Status Authenticate( string collectionID )
 {
     HttpWebResponse response = null;
        Simias.Authentication.Status status =
     new Simias.Authentication.Status( SCodes.Unknown );
        Store store = Store.GetStore();
        Simias.Storage.Domain domain = store.GetDomain( GaimDomain.ID );
        Simias.Storage.Member member = domain.GetCurrentMember();
        GaimDomainProvider gaimDomainProvider = new GaimDomainProvider();
        Uri remoteUri = gaimDomainProvider.ResolveLocation( GaimDomain.ID, collectionID );
        if ( remoteUri == null )
        {
     status.statusCode = SCodes.UnknownDomain;
     return status;
        }
        Uri loginUri = new Uri( remoteUri.ToString() + "/Login.ashx" );
        HttpWebRequest request = WebRequest.Create( loginUri ) as HttpWebRequest;
        WebState webState = new WebState( GaimDomain.ID );
        webState.InitializeWebRequest( request, GaimDomain.ID );
        request.Headers.Add(
     Simias.Security.Web.AuthenticationService.Login.DomainIDHeader,
     GaimDomain.ID );
        request.Headers.Add( "gaim-member", member.UserID );
        request.Method = "POST";
        request.ContentLength = 0;
        try
        {
     request.GetRequestStream().Close();
     response = request.GetResponse() as HttpWebResponse;
     if ( response != null )
     {
      status.statusCode = SCodes.Success;
     }
        }
        catch(WebException webEx)
        {
     response = webEx.Response as HttpWebResponse;
     if (response != null)
     {
      log.Debug( response.StatusCode.ToString() );
      if ( response.StatusCode == System.Net.HttpStatusCode.Unauthorized )
      {
       string oneTimeChallenge = response.Headers[ "gaim-secret" ];
       if ( oneTimeChallenge != null && oneTimeChallenge != "" )
       {
        HttpWebRequest request2 = WebRequest.Create( loginUri ) as HttpWebRequest;
        WebState webState2 = new WebState( GaimDomain.ID );
        webState2.InitializeWebRequest( request2, GaimDomain.ID );
        request2.CookieContainer.Add(response.Cookies);
        request2.Headers.Add(
     Simias.Security.Web.AuthenticationService.Login.DomainIDHeader,
     GaimDomain.ID );
        request2.Headers.Add( "gaim-member", member.UserID );
        try
        {
     RSACryptoServiceProvider credential = GaimDomain.GetCredential();
     if (credential != null)
     {
      byte[] oneTime = Convert.FromBase64String( oneTimeChallenge );
      byte[] decryptedText = credential.Decrypt( oneTime, false );
      request2.Headers.Add( "gaim-secret", Convert.ToBase64String( decryptedText ) );
     }
     else
     {
      log.Debug( "Couldn't get our own RSACryptoServiceProvider (our private key)" );
      status.statusCode = SCodes.Unknown;
      return status;
     }
        }
        catch( Exception enc )
        {
     log.Debug( "Error decrypting one time secret." );
     log.Debug( enc.Message );
     log.Debug( enc.StackTrace );
        }
        request2.Method = "POST";
        request2.ContentLength = 0;
        try
        {
     request2.GetRequestStream().Close();
     response = request2.GetResponse() as HttpWebResponse;
     if ( response != null )
     {
      status.statusCode = SCodes.Success;
     }
        }
        catch( WebException webEx2 )
        {
     log.Debug( "WebException: " + webEx2.Status.ToString() );
     log.Debug( webEx2.Message );
     log.Debug( webEx2.StackTrace );
        }
        catch( Exception e2 )
        {
     log.Debug( "Other exception" );
     log.Debug( e2.Message );
     log.Debug( e2.StackTrace );
        }
       }
       else
       {
        log.Debug( "One Time Challenge NOT present");
       }
      }
     }
     else
     {
      log.Debug( "Couldn't get the HttpWebResponse" );
      log.Debug(webEx.Message);
      log.Debug(webEx.StackTrace);
     }
        }
        catch(Exception ex)
        {
     log.Debug( "Catch-all Exception" );
     log.Debug(ex.Message);
     log.Debug(ex.StackTrace);
        }
        return status;
 }
        private void SendHttpWebRequest(Dictionary<string, string> headers, FunapiMessage body)
        {
            // Request
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(host_url_);
            request.Method = "POST";
            request.ContentType = "application/x-www-form-urlencoded";
            request.ContentLength = body.buffer.Count;

            foreach (KeyValuePair<string, string> item in headers) {
                request.Headers[item.Key] = item.Value;
            }

            // Response
            WebState ws = new WebState();
            ws.request = request;
            ws.msg_type = body.msg_type;
            ws.sending = body.buffer;
            list_.Add(ws);

            cur_request_ = ws;
            request.BeginGetRequestStream(new AsyncCallback(RequestStreamCb), ws);
        }
        private void ClearRequest()
        {
            cur_www_ = null;
            cur_request_ = null;
            last_error_code_ = ErrorCode.kNone;
            last_error_message_ = "";

            if (Timer.ContainTimer(kTimeoutTimerId))
                Timer.KillTimer(kTimeoutTimerId);
        }
        private void ClearRequest()
        {
            #if !NO_UNITY
            cur_www_ = null;
            #endif
            cur_request_ = null;
            last_error_code_ = ErrorCode.kNone;
            last_error_message_ = "";

            timer_.KillTimer(kTimeoutTimerId);
        }