home *** CD-ROM | disk | FTP | other *** search
/ Computer Active 2010 August / CA08.iso / Multimedija / shufflr.air / ShufflrClient.swf / scripts / com / facebook / utils / PostRequest.as < prev   
Encoding:
Text File  |  2010-06-23  |  3.2 KB  |  122 lines

  1. package com.facebook.utils
  2. {
  3.    import flash.utils.ByteArray;
  4.    import flash.utils.Endian;
  5.    
  6.    public class PostRequest
  7.    {
  8.       protected var _boundary:String = "-----";
  9.       
  10.       protected var postData:ByteArray;
  11.       
  12.       public function PostRequest()
  13.       {
  14.          super();
  15.          this.createPostData();
  16.       }
  17.       
  18.       public function getPostData() : ByteArray
  19.       {
  20.          this.postData.position = 0;
  21.          return this.postData;
  22.       }
  23.       
  24.       protected function writeBoundary() : void
  25.       {
  26.          this.writeDoubleDash();
  27.          var _loc1_:Number = 0;
  28.          while(_loc1_ < this.boundary.length)
  29.          {
  30.             this.postData.writeByte(this.boundary.charCodeAt(_loc1_));
  31.             _loc1_++;
  32.          }
  33.       }
  34.       
  35.       protected function writeDoubleDash() : void
  36.       {
  37.          this.postData.writeShort(11565);
  38.       }
  39.       
  40.       public function writeFileData(param1:String, param2:ByteArray, param3:String) : void
  41.       {
  42.          var _loc4_:String = null;
  43.          this.writeBoundary();
  44.          this.writeLineBreak();
  45.          _loc4_ = "Content-Disposition: form-data; filename=\"";
  46.          var _loc5_:Number = 0;
  47.          while(_loc5_ < _loc4_.length)
  48.          {
  49.             this.postData.writeByte(_loc4_.charCodeAt(_loc5_));
  50.             _loc5_++;
  51.          }
  52.          this.postData.writeUTFBytes(param1);
  53.          this.writeQuotationMark();
  54.          this.writeLineBreak();
  55.          _loc4_ = param3;
  56.          _loc5_ = 0;
  57.          while(_loc5_ < _loc4_.length)
  58.          {
  59.             this.postData.writeByte(_loc4_.charCodeAt(_loc5_));
  60.             _loc5_++;
  61.          }
  62.          this.writeLineBreak();
  63.          this.writeLineBreak();
  64.          param2.position = 0;
  65.          this.postData.writeBytes(param2,0,param2.length);
  66.          this.writeLineBreak();
  67.       }
  68.       
  69.       public function createPostData() : void
  70.       {
  71.          this.postData = new ByteArray();
  72.          this.postData.endian = Endian.BIG_ENDIAN;
  73.       }
  74.       
  75.       public function writePostData(param1:String, param2:String) : void
  76.       {
  77.          var _loc3_:* = null;
  78.          this.writeBoundary();
  79.          this.writeLineBreak();
  80.          _loc3_ = "Content-Disposition: form-data; name=\"" + param1 + "\"";
  81.          var _loc4_:uint = uint(_loc3_.length);
  82.          var _loc5_:Number = 0;
  83.          while(_loc5_ < _loc4_)
  84.          {
  85.             this.postData.writeByte(_loc3_.charCodeAt(_loc5_));
  86.             _loc5_++;
  87.          }
  88.          this.writeLineBreak();
  89.          this.writeLineBreak();
  90.          this.postData.writeUTFBytes(param2);
  91.          this.writeLineBreak();
  92.       }
  93.       
  94.       public function get boundary() : String
  95.       {
  96.          return this._boundary;
  97.       }
  98.       
  99.       protected function writeLineBreak() : void
  100.       {
  101.          this.postData.writeShort(3338);
  102.       }
  103.       
  104.       public function close() : void
  105.       {
  106.          this.writeBoundary();
  107.          this.writeDoubleDash();
  108.       }
  109.       
  110.       protected function writeQuotationMark() : void
  111.       {
  112.          this.postData.writeByte(34);
  113.       }
  114.       
  115.       public function set boundary(param1:String) : void
  116.       {
  117.          this._boundary = param1;
  118.       }
  119.    }
  120. }
  121.  
  122.