@@ -7,18 +7,21 @@ var http = require('http'),
7
7
N3 = require ( 'n3' ) ,
8
8
n3parser = N3 . Parser ,
9
9
N3Util = N3 . Util ,
10
- Util = require ( '../Util' ) ;
10
+ Util = require ( '../Util' ) ,
11
+ Controller = require ( './Controller' ) ;
11
12
12
13
var CERT_NS = 'http://www.w3.org/ns/auth/cert#' ;
13
14
14
15
// Creates a new WebIDControllerExtension
15
16
function WebIDControllerExtension ( settings ) {
16
17
if ( ! ( this instanceof WebIDControllerExtension ) )
17
18
return new WebIDControllerExtension ( settings ) ;
19
+ Controller . call ( this , settings ) ;
18
20
19
21
this . _cache = lru ( 50 ) ;
20
22
this . _protocol = settings . protocol ;
21
23
}
24
+ Controller . extend ( WebIDControllerExtension ) ;
22
25
23
26
// Add WebID Link headers
24
27
WebIDControllerExtension . prototype . _handleRequest = function ( request , response , next , settings ) {
@@ -94,14 +97,22 @@ WebIDControllerExtension.prototype._verifyWebID = function (webID, modulus, expo
94
97
} ) ;
95
98
96
99
req . on ( 'error' , function ( e ) {
97
- callback ( null , false , 'Unabled to download' + webID + '. Details: ' + e . message ) ;
100
+ callback ( null , false , 'Unabled to download ' + webID + ' ( ' + e . message + ').' ) ;
98
101
} ) ;
99
102
100
103
req . end ( ) ;
101
104
}
102
105
} ;
103
106
104
107
WebIDControllerExtension . prototype . _handleForbidden = function ( request , response , options ) {
108
+ // Render the 404 message using the appropriate view
109
+ var view = this . _negotiateView ( 'Forbidden' , request , response ) ,
110
+ metadata = { url : request . url , prefixes : this . _prefixes , datasources : this . _datasources , reason : options . reason } ;
111
+ response . writeHead ( 401 ) ;
112
+ view . render ( metadata , request , response ) ;
113
+ } ;
114
+
115
+ WebIDControllerExtension . prototype . _handleNotAcceptable = function ( request , response , options ) {
105
116
response . writeHead ( 401 , { 'Content-Type' : Util . MIME_PLAINTEXT } ) ;
106
117
response . end ( 'Access to ' + request . url + ' is not allowed, verification for WebID ' + ( options . webID || '' ) + ' failed. Reason: ' + ( options . reason || '' ) ) ;
107
118
} ;
0 commit comments