33const HttpError = require ( 'standard-http-error' )
44
55class LdpRequest {
6+ /**
7+ * @param options {object}
8+ *
9+ * @param options.host {SolidHost} Host / config object
10+ *
11+ * @param options.target {URL} Parsed full request url
12+ *
13+ * @param options.req {HttpRequest} Save the Express req object, useful
14+ * to access headers/preferences, writeStream for body, etc.
15+ *
16+ * @param [options.authn=null] {object} Authentication object, contains WebID
17+ * string, as well as any bearer credentials/tokens. Needed for
18+ * authenticated fetch (of remote group ACLs, of Copy resources, etc).
19+ * Null if request is not authenticated.
20+ *
21+ * @param [options.parsedBody] {?} Request body, parsed when appropriate
22+ * (when content-type is parse-able)
23+ */
24+ constructor ( options ) {
25+ this . host = options . host
26+ this . target = options . target
27+ this . req = options . req
28+ this . authn = options . authn
29+ this . parsedBody = options . parsedBody
30+ }
31+
632 static from ( { req, host} ) {
733 let request
834
@@ -74,7 +100,8 @@ class LdpRequest {
74100 * Deletes resource or container
75101 *
76102 * Throws:
77- * - 404 error if resource does not exist
103+ * - 404 error if resource or container does not exist
104+ * - 409 Conflict error if deleting a non-empty container
78105 */
79106 request = LdpDeleteRequest . from ( { req, host} )
80107 break
@@ -95,7 +122,8 @@ class LdpRequest {
95122 * private resources.
96123 *
97124 * Throws:
98- * - 400 Source header required error if Source: header is missing
125+ * - 400 'Source header required' error if Source: header is missing
126+ * - 404 if source resource is not found
99127 */
100128 request = LdpCopyRequest . from ( { req, host} )
101129 break
0 commit comments