- public static function doSessionIdDownload( $session_id, $upload_session_key ){
- global $wgUser, $wgEnableWriteAPI, $wgAsyncHTTPTimeout, $wgServer;
- wfDebug( __METHOD__ . "\n\ndoSessionIdDownload:\n\n" );
-
- // set session to the provided key:
- session_id( $session_id );
- // start the session
- if( session_start() === false ){
- wfDebug( __METHOD__ . ' could not start session' );
- }
- // get all the vars we need from session_id
- if( !isset( $_SESSION[ 'wsDownload' ][$upload_session_key] ) ){
- wfDebug( __METHOD__ . ' Error:could not find upload session');
- exit();
- }
- // setup the global user from the session key we just inherited
- $wgUser = User::newFromSession();
-
- // grab the session data to setup the request:
- $sd =& $_SESSION['wsDownload'][$upload_session_key];
-
- // update the wgServer var ( since cmd line thinks we are localhost when we are really orgServer)
- if( isset( $sd['orgServer'] ) && $sd['orgServer'] ){
- $wgServer = $sd['orgServer'];
- }
- // close down the session so we can other http queries can get session updates:
- session_write_close();
-
- $req = new HttpRequest( $sd['url'], array(
- 'target_file_path' => $sd['target_file_path'],
- 'upload_session_key'=> $upload_session_key,
- 'timeout' => $wgAsyncHTTPTimeout,
- 'do_close_session_update' => true
- ) );
- // run the actual request .. (this can take some time)
- wfDebug( __METHOD__ . 'do Request: ' . $sd['url'] . ' tf: ' . $sd['target_file_path'] );
- $status = $req->doRequest();
- //wfDebug("done with req status is: ". $status->isOK(). ' '.$status->getWikiText(). "\n");
-
- // start up the session again:
- if( session_start() === false ){
- wfDebug( __METHOD__ . ' ERROR:: Could not start session');
- }
- // grab the updated session data pointer
- $sd =& $_SESSION['wsDownload'][$upload_session_key];
- // if error update status:
- if( !$status->isOK() ){
- $sd['apiUploadResult'] = ApiFormatJson::getJsonEncode(
- array( 'error' => $status->getWikiText() )
- );
- }
- // if status okay process upload using fauxReq to api:
- if( $status->isOK() ){
- // setup the FauxRequest
- $fauxReqData = $sd['mParams'];
-
- // Fix boolean parameters
- foreach( $fauxReqData as $k => $v ) {
- if( $v === false )
- unset( $fauxReqData[$k] );
+ protected function parseHeader() {
+ $lastname = "";
+
+ foreach ( $this->headerList as $header ) {
+ if ( preg_match( "#^HTTP/([0-9.]+) (.*)#", $header, $match ) ) {
+ $this->respVersion = $match[1];
+ $this->respStatus = $match[2];
+ } elseif ( preg_match( "#^[ \t]#", $header ) ) {
+ $last = count( $this->respHeaders[$lastname] ) - 1;
+ $this->respHeaders[$lastname][$last] .= "\r\n$header";
+ } elseif ( preg_match( "#^([^:]*):[\t ]*(.*)#", $header, $match ) ) {
+ $this->respHeaders[strtolower( $match[1] )][] = $match[2];
+ $lastname = strtolower( $match[1] );