<commit_before>/*
 * Direct-HTTP read-only file system used to
 * access all unknown, default resources.
 */

import { Base } from './base.jsx'

export default class Filesystem extends Base {
    read(path) {
        return fetch(path).then((response) => {
            if(response.ok) {
                response.text()
            } else {
                throw new Error(`httpfs error: ${response.status} ${response.statusText}`)
            }
        })
    }
}<commit_msg>Add full request passthru to httpfs<commit_after>/*
 * Direct-HTTP read-only file system used to
 * access all unknown, default resources.
 */

import { Base } from './base.jsx'

export default class Filesystem extends Base {
    constructor(path, options) {
        super('httpfs', path, options)

        if(!options.base)
            throw new Error('Option `base` required.')

        this.base = options.base
    }

    read(path, request) {
        let req = new Request(this.base + '/' + path, request)

        return fetch(req)
    }

    write(path, _, request) {
        let req = new Request(this.base + '/' + path, request)

        return fetch(req)
    }

    stat(path, request) {
        let req = new Request(this.base + '/' + path, request)

        return fetch(req)
    }
}
{'fraction_non_alphanumeric': 0.12529550827423167, 'fraction_numerical': 0.0, 'mean_word_length': 2.1358024691358026, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4850794', 'n_tokens_mistral': 373, 'n_tokens_neox': 361, 'n_words': 104}