| 23 | } |
| 24 | |
| 25 | handleHttpRequest(request, response) { |
| 26 | if(!this.receiving) return; |
| 27 | |
| 28 | let scopes = ["server"]; |
| 29 | let requestId = `request|${this.requestId++}|${(new Date()).getTime()}` |
| 30 | this.requestToResponse[requestId] = response; |
| 31 | let actions = [ |
| 32 | new InsertAction("server|tag", requestId, "tag", "request", undefined, scopes), |
| 33 | new InsertAction("server|url", requestId, "url", request.url, undefined, scopes), |
| 34 | ]; |
| 35 | if(request.headers) { |
| 36 | let headerId = `${requestId}|body`; |
| 37 | for(let key of Object.keys(request.headers)) { |
| 38 | actions.push(new InsertAction("server|header", headerId, key, request.headers[key], undefined, scopes)); |
| 39 | } |
| 40 | actions.push(new InsertAction("server|headers", requestId, "headers", headerId, undefined, scopes)) |
| 41 | } |
| 42 | if(request.body) { |
| 43 | let body = request.body; |
| 44 | if(typeof body === "string") { |
| 45 | // nothing we need to do |
| 46 | } else { |
| 47 | let bodyId = `${requestId}|body`; |
| 48 | for(let key of Object.keys(body)) { |
| 49 | actions.push(new InsertAction("server|request-body-entry", bodyId, key, body[key], undefined, scopes)); |
| 50 | } |
| 51 | body = bodyId; |
| 52 | } |
| 53 | actions.push(new InsertAction("server|request-body", requestId, "body", body, undefined, scopes)) |
| 54 | } |
| 55 | let evaluation = this.evaluations[0]; |
| 56 | evaluation.executeActions(actions); |
| 57 | } |
| 58 | |
| 59 | analyze(evaluation: Evaluation, db: Database) { |
| 60 | for(let block of db.blocks) { |