@@ -121,26 +121,25 @@ Fragment.prototype._read = function (count, done) {
121121// Loads the Triple Pattern Fragment located at the given URL
122122Fragment . prototype . loadFromUrl = function ( pageUrl ) {
123123 // Fetch a page of the fragment
124- var fragment = this , fragmentsClient = this . _fragmentsClient , page ,
124+ var fragment = this , fragmentsClient = this . _fragmentsClient , rawPage ,
125125 headers = { 'user-agent' : 'Triple Pattern Fragments Client' } ;
126126 if ( fragmentsClient . _startFragmentUrl ) headers . referer = fragmentsClient . _startFragmentUrl ;
127- page = fragmentsClient . _httpClient . get ( pageUrl , headers ) ;
128- page . on ( 'error' , function ( error ) { fragment . emit ( 'error' , error ) ; } ) ;
127+ rawPage = fragmentsClient . _httpClient . get ( pageUrl , headers ) ;
128+ rawPage . on ( 'error' , function ( error ) { fragment . emit ( 'error' , error ) ; } ) ;
129129
130- page . getProperty ( 'statusCode' , function ( statusCode ) {
131- // Don't parse the page if its retrieval was unsuccessful
130+ // Parse the raw page when the response arrives, extracting data, metadata, and controls
131+ rawPage . getProperty ( 'statusCode' , function ( statusCode ) {
132132 if ( statusCode !== 200 ) {
133- page . emit ( 'error' , new Error ( 'Could not retrieve ' + pageUrl + ' (' + statusCode + ')' ) ) ;
133+ rawPage . emit ( 'error' , new Error ( 'Could not retrieve ' + pageUrl + ' (' + statusCode + ')' ) ) ;
134134 return fragment . close ( ) ;
135135 }
136136
137- // Obtain the page's data, metadata, and controls
138- page . getProperty ( 'contentType' , function ( contentType ) {
139- // Parse the page using the appropriate parser for the content type
137+ // Parse the raw page using the appropriate parser for the content type
138+ rawPage . getProperty ( 'contentType' , function ( contentType ) {
140139 var Parser = _ . find ( parserTypes , function ( P ) { return P . supportsContentType ( contentType ) ; } ) ;
141140 if ( ! Parser )
142141 return fragment . emit ( 'error' , new Error ( 'No parser for ' + contentType + ' at ' + pageUrl ) ) ;
143- var parsedPage = fragment . _page = new Parser ( page , pageUrl ) ;
142+ var parsedPage = fragment . _page = new Parser ( rawPage , pageUrl ) ;
144143 parsedPage . on ( 'readable' , function ( ) { fragment . readable = true ; } ) ;
145144
146145 // Extract the page's metadata and controls
0 commit comments