mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-20 23:06:16 -04:00
ESM: Ported Punycode, HTTP and PRNG operations
This commit is contained in:
parent
0d1e5311dc
commit
c29ea53405
6 changed files with 427 additions and 0 deletions
42
src/core/operations/StripHTTPHeaders.mjs
Normal file
42
src/core/operations/StripHTTPHeaders.mjs
Normal file
|
@ -0,0 +1,42 @@
|
|||
/**
|
||||
* @author n1474335 [n1474335@gmail.com]
|
||||
* @copyright Crown Copyright 2016
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Operation from "../Operation";
|
||||
|
||||
/**
|
||||
* Strip HTTP headers operation
|
||||
*/
|
||||
class StripHTTPHeaders extends Operation {
|
||||
|
||||
/**
|
||||
* StripHTTPHeaders constructor
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.name = "Strip HTTP headers";
|
||||
this.module = "Default";
|
||||
this.description = "Removes HTTP headers from a request or response by looking for the first instance of a double newline.";
|
||||
this.inputType = "string";
|
||||
this.outputType = "string";
|
||||
this.args = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
run(input, args) {
|
||||
let headerEnd = input.indexOf("\r\n\r\n");
|
||||
headerEnd = (headerEnd < 0) ? input.indexOf("\n\n") + 2 : headerEnd + 4;
|
||||
|
||||
return (headerEnd < 2) ? input : input.slice(headerEnd, input.length);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default StripHTTPHeaders;
|
Loading…
Add table
Add a link
Reference in a new issue