import CodeSnippet from '../CodeSnippet.js';
import 'prismjs/components/prism-http.min.js';
export default class RawSnippet extends CodeSnippet {
    lang = 'http';
    computeCommand(url, method, headers, payload) {
        if (!url || !method) {
            return '';
        }
        const urlData = this.urlDetails(url);
        let result = `${method} ${urlData.path} HTTP/1.1\n`;
        if (urlData.hostValue) {
            result += `Host: ${urlData.hostValue}:${urlData.port}\n`;
        }
        result += this._genHeadersPart(headers);
        result += this._genPayloadPart(payload);
        return result;
    }
    _genHeadersPart(headers) {
        let result = '';
        if (headers) {
            for (const [name, value] of headers) {
                result += `${name}: ${value}\n`;
            }
        }
        return result;
    }
    _genPayloadPart(payload) {
        let result = '';
        if (typeof payload === 'string') {
            result += '\n';
            result += payload;
            result += '\n\n';
        }
        return result;
    }
}
//# sourceMappingURL=RawSnippet.js.map