Changeset 26346


Ignore:
Timestamp:
07/13/21 14:19:31 (4 years ago)
Author:
jdquinn
Message:

CHG: Uncommitted changes to issm-binaries.js -> partial

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/classes/clusters/generic.js

    r22894 r26346  
    115115               
    116116                // Set request properties
    117                 request.position        = 0; // Keep track of current parsing position in repsonseText
    118                 request.timeout         = 1000 * 60 * 60 * 3; // 3 hrs (in milliseconds); NOTE: This should match FastCgiServer timeout in Apache conf
     117                request.position         = 0; // Keep track of current parsing position in repsonseText
     118                request.timeout         = 1000 * 60 * 10; // in milliseconds; NOTE: Under current implementation, this should match 'Timeout' option in Apache conf (/etc/apache2/apache2.conf)
     119                request.resultBegin = false;
    119120               
    120121                request.ontimeout = function(event) { //{{{
     
    187188                                        }
    188189                                } else if (request.responseText.length >= endIndex) { // Ensure entire chunk is loaded
    189                                         progress = parseInt(request.responseText.slice(startIndex, endIndex));
     190                                        if (request.resultBegin) {
     191                                                return;
     192                                        }
     193                                        chunk = request.responseText.slice(startIndex, endIndex)
     194                                        if (chunk == 'RESULT_BEGIN') {
     195                                                progress = 100;
     196                                                request.resultBegin = true;
     197                                        } else {
     198                                                progress = parseInt(chunk);
     199                                        }
    190200                                        if (hasCallout) {
    191201                                                callout.setHeader('Computing...');
     
    221231                       
    222232                        try {
    223 /*
    224                                 console.log(request.responseText);
    225                                 console.log('request.position : ' + request.position);
    226                                 console.log('request.responseType : ' + request.responseType);
    227                                 console.log('request.responseText.length : ' + request.responseText.length);
    228 */
     233                                //Scan through buffer until progress updates stop and 'RESULT_BEGIN' string is received
     234                                let startIndex  = request.position;
     235                                let endIndex    = request.position + 10;
     236                                let chunkSize = 0;
     237                                let chunk = 0;
     238                                while (!request.resultBegin && chunk != 'RESULT_BEGIN') {
     239                                        chunkSize = parseInt(request.responseText.slice(startIndex, endIndex));
     240                                        startIndex      = endIndex;
     241                                        endIndex        = startIndex + chunkSize;
     242                                        chunk = request.responseText.slice(startIndex, endIndex);
     243                                        startIndex      = endIndex;
     244                                        endIndex        = startIndex + 10;
     245                                        request.position = startIndex;
     246                                }
     247
    229248                                responseText    = window.atob(request.responseText.slice(request.position + 10).replace(/\s/g, ''));
    230 //                              console.log('responseText.length : ' + responseText.length);
    231249                                buffer                  = str2ab(responseText);
    232 //                              console.log('buffer.length : ' + buffer.length);
    233250/*
    234251                    bufferInflated      = UZIP.inflate(buffer);
     
    248265                                // Let front end script handle changes to callout
    249266                                if (hasCallout) {
    250                                         callout.set('Success!', '<p>Solve successful</p>');
     267                                        callout.set('Success!', '<p>Request successful</p>');
    251268                                } else {
    252269                                        solveButton.text(solveButtonText).prop('disabled', false);
     
    255272                        } catch (e) {
    256273                                console.log(e);
    257                                 if (vesl.string.startsWith(responseText, 'Error')) {
     274                                if (vesl.strings.startsWith(responseText, 'Error')) {
    258275                                        if (hasCallout) {
    259276                                                callout.set(vesl.ERROR_HEADER_GENERAL, '<p>Something went wrong. ' + vesl.ERROR_CONTENT_TRY_AGAIN + '</p>');
     
    272289                }; //}}}
    273290               
    274                 request.responseType = 'application/octet-stream';
     291                request.responseType = 'text';
    275292               
    276293                /* Construct request */
Note: See TracChangeset for help on using the changeset viewer.