123456 |
- // Licensed Materials - Property of IBM
- // IBM Cognos Products: hal
- // (C) Copyright IBM Corp. 2003, 2017.
- // US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- function C_WebRequest(_hLN1, _hM12, _hID2, _hQ72, _h4B2, _hZR1){this._hXN1=_hLN1;this._h732=_hM12;this._hJD2=_hID2;this._hR72=(_hQ72!==false);this._h5B2=_h4B2;this._h0S1=_hZR1;this._hRO1=true;this._h372=null;this._hNP=[];};C_WebRequest.prototype.F_GetListener=function(){return this._hXN1;};C_WebRequest.prototype.F_SetListener=function(_hLN1){this._hXN1=_hLN1;};C_WebRequest.prototype.F_SetNewError=function(_h0Y,_h1Y,_hWH1){this._h372=new C_Error( _h0Y||"Web request failed.", _h1Y, _hWH1 );};C_WebRequest.prototype.F_SetNewErrorRes=function(_hNK,_h1Y,_hWH1){this.F_SetNewError(window["G_ResManager"]?G_ResManager.F_GetString(_hNK):null, _h1Y, _hWH1);};C_WebRequest.prototype.F_SetError=function(_hW52){this._h372=_hW52;};C_WebRequest.prototype.F_GetError=function(){return this._h372;};C_WebRequest.prototype.F_SetRequestHeader=function(_h492,_h552){this._hNP.push(_h492, _h552);};C_WebRequest.prototype.F_GetResponseHeader=function(_h492){return this._hSX1.getResponseHeader(_h492);};C_WebRequest.prototype.F_SetRequestBody=function(_h571){this._hQ71=_h571;};C_WebRequest.prototype.F_GetRequestBody=function(){return this._hQ71;};C_WebRequest.prototype.F_Send=function(){if(G_HAL.M_oTestListener&&G_HAL.M_oTestListener.F_WebRequest_OnSend){G_HAL.M_oTestListener.F_WebRequest_OnSend(this);}if(this._hSX1){this._hSX1=null;}this._hAJ1=false;C_WebRequest.F_AddActiveRequest(this);this._hSX1=(U_XML.M_bUseNativeXMLHttpRequest&&window.XMLHttpRequest)?new XMLHttpRequest():new ActiveXObject(U_XML.K_sProgID_XMLHTTP);try{if(this._h5B2||this._h0S1){this._hSX1.open(this._h732, this._hJD2, this._hR72, this._h5B2, this._h0S1);}else{this._hSX1.open(this._h732, this._hJD2, this._hR72);}}catch(e){G_Debug.F_Print( "Error opening C_WebRequest request" );this.F_SetNewErrorRes( "IDS_HAL_WEBREQUEST_SEND_ERROR", "URL: " + this._hJD2);if(this._hXN1&&this._hXN1.F_Request_OnComplete){this._hXN1.F_Request_OnComplete(this);}return;}if(G_BrowserInfo.M_bIsFirefox){var _hKD2=this._hJD2.substr(this._hJD2.length-".dtd".length);if(_hKD2==".dtd"){this._hSX1.overrideMimeType("text/plain");}}for(var i=0;i<this._hNP.length;i+= 2){this._hSX1.setRequestHeader(this._hNP[i], this._hNP[i+1]);}if(!this._hRO1){this._hSX1.setRequestHeader( "If-Modified-Since", "Thu, 01 Jan 1970 00:00:00 GMT" );}this._hSX1.onreadystatechange=this._h4F.bind(this);try{this._hSX1.send(this._hQ71||"");}catch(e){G_Debug.F_Print( "Error sending C_WebRequest request" );this.F_SetNewErrorRes("IDS_HAL_WEBREQUEST_SEND_ERROR");if(this._hXN1&&this._hXN1.F_Request_OnComplete){this._hXN1.F_Request_OnComplete(this);}}};C_WebRequest.prototype.M_iResponseDelay=0;C_WebRequest.prototype._h4F=function(){if(!this._hQW1&&(this._hSX1.readyState==4)){C_WebRequest.F_RemoveActiveRequest(this);this._hAJ1=true;this._hSX1.onreadystatechange=U_DOM.F_EmptyFunction;if(!this.F_IsSuccessStatus()){var _h0Y=window["G_ResManager"]?G_ResManager.F_GetOptionalString( "IDS_HAL_WEBREQUEST_ERROR" ):null;var _h1Y=this.F_GetStatus()+" - " + this.F_GetStatusText() + "\n" +"URL: " + this.F_GetUrl();var _hG11=this.F_GetResponseText();if(_hG11){_h1Y += "\n\nResponse Text:\n" + _hG11;}G_HAL.F_VerifyDependencies("C_Error");this.F_SetNewError(_h0Y, _h1Y, "");}if(this.M_iResponseDelay){setTimeout(this._h4A.bind(this), this.M_iResponseDelay);return;}this._h4A();}};C_WebRequest.prototype._h4A=function(){if(this._hQW1){return;}if(!this.F_IsReadyToProcess()){return;}this.F_ProcessResponse();if(this._hXN1&&this._hXN1.F_Request_OnComplete){this._hXN1.F_Request_OnComplete(this);}};C_WebRequest.prototype.F_ProcessResponse=function(){if(G_HAL.M_oTestListener&&G_HAL.M_oTestListener.F_WebRequest_OnProcessResponse){G_HAL.M_oTestListener.F_WebRequest_OnProcessResponse(this);}if(this._h372){G_Debug.F_Print(this._h372.F_GetErrorSummary()+"\n" + this._h372.F_GetErrorDetails());}};C_WebRequest.prototype.F_IsReadyToProcess=function(){return true;};C_WebRequest.prototype.F_Abort=function(){this._hQW1=true;C_WebRequest.F_RemoveActiveRequest(this);if(this._hSX1){this._hSX1.abort();this._hSX1=null;}if(!this._hAJ1&&this._hXN1&&this._hXN1.F_Request_OnAborted){this._hAJ1=true;this._hXN1.F_Request_OnAborted(this);}};C_WebRequest.prototype.F_IsSuccessStatus=function(){var _h832=this.F_GetStatus();return((_h832>=200)&&(_h832<300));};C_WebRequest.prototype.F_GetStatus=function(){return U_DOM.F_GetPropertyInTryCatch(this._hSX1, "status");};C_WebRequest.prototype.F_GetStatusText=function(){return U_DOM.F_GetPropertyInTryCatch(this._hSX1, "statusText");};C_WebRequest.prototype.F_GetUrl=function(){return this._hJD2;};C_WebRequest.prototype.F_GetResponseText=function(){return this._hSX1.responseText;};C_WebRequest.prototype.F_SetCaching=function(_hTO1){this._hRO1=_hTO1;};C_WebRequest.prototype.F_SetContext=function(_hUV1){this._hVV1=_hUV1;};C_WebRequest.prototype.F_GetContext=function(){return this._hVV1;};C_WebRequest._h0Q=[];C_WebRequest.F_AbortActiveRequests=function(){var _h1Q=this._h0Q.concat();for(var i=0;i<_h1Q.length;i++){var _hWU1=_h1Q[i];_hWU1._hXN1=null;_hWU1.F_Abort();}};C_WebRequest.F_AddActiveRequest=function(_hWU1){this._h0Q.push(_hWU1);};C_WebRequest.F_RemoveActiveRequest=function(_hWU1){this._h0Q.F_RemoveItem(_hWU1);};C_WebRequest.F_HasActiveRequests=function(){return(this._h0Q.length>0);};
|