@@ -20,17 +20,12 @@ var HttpError = require('../http-error');
2020
2121var ldpVocab = require ( '../vocab/ldp.js' ) ;
2222
23- function get ( req , res , next , includeBody ) {
23+ function get ( req , res , next ) {
2424 var ldp = req . app . locals . ldp ;
2525 var uri = utils . uriBase ( req ) ;
2626 var filename = utils . uriToFilename ( req . path , ldp . root ) ;
2727
28- // // Add request to subscription service
29- // if (req.path.slice(-ldp.suffixChanges.length) ===
30- // ldp.suffixChanges) {
31- // debug("GET -- Subscribed to " + req.originalUrl);
32- // return subscription.subscribeToChanges(req, res);
33- // }
28+ var includeBody = req . method === 'GET'
3429
3530 // Parse accept mime types into a priority (q) ordered array
3631 res . acceptTypes = header . negotiateContentType ( req ) || 'text/turtle' ;
@@ -40,19 +35,10 @@ function get(req, res, next, includeBody) {
4035
4136 // Set live updates
4237 if ( ldp . live ) {
43- // Note not yet in
44- // http://www.iana.org/assignments/link-relations/link-relations.xhtml
45- // header.addLink(res, req.originalUrl + ldp.suffixChanges, 'changes');
46- // res.header('Link' , '' + req.path + ldp.suffixSSE + ' ; rel=events' );
47- // overwrites the pevious
4838 res . header ( 'Updates-Via' , utils . uriBase ( req ) ) ;
4939 }
5040
51- if ( includeBody ) {
52- debug ( 'GET -- ' + req . originalUrl ) ;
53- } else {
54- debug ( 'HEAD -- ' + req . originalUrl ) ;
55- }
41+ debug ( req . method + ' -- ' + req . originalUrl ) ;
5642
5743 // Get resource or container
5844 ldp . get ( filename , uri , includeBody , function ( err , data , container ) {
@@ -72,7 +58,8 @@ function get(req, res, next, includeBody) {
7258 // Just return that file exists
7359 // data is of `typeof 'string'` if file is empty, but exists!
7460 if ( data === undefined ) {
75- return res . sendStatus ( 200 ) ;
61+ res . sendStatus ( 200 ) ;
62+ return next ( ) ;
7663 }
7764
7865 // Container/resource retrieved
@@ -87,9 +74,10 @@ function get(req, res, next, includeBody) {
8774
8875 // if data is not text/turtle, just send it
8976 if ( contentType !== 'text/turtle' ) {
90- return res
77+ res
9178 . status ( 200 )
9279 . send ( data ) ;
80+ return next ( ) ;
9381 }
9482 }
9583
@@ -192,9 +180,10 @@ function parseLinkedData(req, res, next) {
192180 accept === 'text/n3' ||
193181 accept === 'application/turtle' ||
194182 accept === 'application/n3' ) {
195- return res . status ( 200 )
183+ res . status ( 200 )
196184 . set ( 'content-type' , accept )
197185 . send ( turtleData ) ;
186+ return next ( ) ;
198187 }
199188
200189 //Handle other file types
@@ -219,21 +208,13 @@ function parseLinkedData(req, res, next) {
219208 status : 500
220209 } ) ) ;
221210 }
222-
223- return res
211+ res
224212 . status ( 200 )
225213 . set ( 'content-type' , accept )
226214 . send ( result ) ;
227- } ) ;
228- }
229215
230- function getHandler ( req , res , next ) {
231- get ( req , res , next , true ) ;
232- }
233-
234- function headHandler ( req , res , next ) {
235- get ( req , res , next , false ) ;
216+ return next ( ) ;
217+ } ) ;
236218}
237219
238- exports . handler = getHandler ;
239- exports . headHandler = headHandler ;
220+ exports . handler = get ;
0 commit comments