Skip to content

Instantly share code, notes, and snippets.

@linonetwo
Created May 24, 2019 08:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save linonetwo/e612315dbbf794a949b998df2247bf7c to your computer and use it in GitHub Desktop.
Save linonetwo/e612315dbbf794a949b998df2247bf7c to your computer and use it in GitHub Desktop.
Head Fields in HTTP #protocol
/** slug field: let parent folder create a resource named ${slug} */
const slug = basename(url);
const parentFolder = dirname(pathName);
const parentUrl = `https://${hostName}${parentFolder}`;
/** link field: links saparated by comma, and key-value saparated by semicolon;
* type means the suggested content-type, describedby means the suggested meatdata file
*/
const link = `<http://www.w3.org/ns/ldp#Resource>; rel="type", <${slug}.meta>; rel="describedby"`;
const creationResponse: Response = await fetch(parentUrl, {
method: 'POST',
headers: { link, slug, 'content-type': contentType },
body: content,
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment