Esempio n. 1
0
        /// <summary>
        /// バイナリアップロード
        /// </summary>
        public HttpStatusCode GetContent(string method,
                                         Uri requestUri,
                                         Dictionary <string, string> param,
                                         List <KeyValuePair <string, FileInfo> > binary,
                                         ref string content,
                                         Dictionary <string, string> headerInfo,
                                         CallbackDelegate callback)
        {
            // 認証済かチェック
            if (string.IsNullOrEmpty(token))
            {
                return(HttpStatusCode.Unauthorized);
            }

            HttpWebRequest webReq = this.CreateRequest(method, requestUri, param, binary, false);

            // OAuth認証ヘッダを付加
            this.AppendOAuthInfo(webReq, null, token, tokenSecret);

            HttpStatusCode code;

            if (content == null)
            {
                code = this.GetResponse(webReq, headerInfo, false);
            }
            else
            {
                code = this.GetResponse(webReq, out content, headerInfo, false);
            }

            if (callback != null)
            {
                StackFrame frame = new StackFrame(1);
                callback(frame.GetMethod().Name, code, content);
            }
            return(code);
        }
Esempio n. 2
0
        /// <summary>
        /// バイナリアップロード
        /// </summary>
        public HttpStatusCode GetContent( string method,
		                                  Uri requestUri,
		                                  Dictionary< string, string > param,
		                                  List< KeyValuePair< string, FileInfo > > binary, 
		                                  ref string content,
		                                  Dictionary< string, string > headerInfo,
		                                  CallbackDelegate callback )
        {
            // 認証済かチェック
            if ( string.IsNullOrEmpty( token ) )
                return HttpStatusCode.Unauthorized;

            HttpWebRequest webReq = this.CreateRequest( method, requestUri, param, binary, false );
            // OAuth認証ヘッダを付加
            this.AppendOAuthInfo( webReq, null, token, tokenSecret );

            HttpStatusCode code;
            if ( content == null )
                code = this.GetResponse( webReq, headerInfo, false );
            else
                code = this.GetResponse( webReq, out content, headerInfo, false );

            if ( callback != null )
            {
                StackFrame frame = new StackFrame( 1 );
                callback( frame.GetMethod().Name, ref code, ref content );
            }
            return code;
        }