-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding support for inspect dumped http interceptions
- Loading branch information
Kanishka Dilshan
committed
Dec 28, 2018
1 parent
7b94d5d
commit 8daca45
Showing
6 changed files
with
229 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const express = require('express'); | ||
const mongoose = require('mongoose'); | ||
|
||
const router = express.Router(); | ||
|
||
//import models | ||
require('../models/HttpInterception'); | ||
require('../models/HttpInterceptionDump'); | ||
require('../models/HttpDump'); | ||
|
||
const HttpDump = mongoose.model('httdump'); | ||
const HttpInterceptionDump = mongoose.model('httpinterceptiondump'); | ||
|
||
router.get('/:id', (req, res) => { | ||
HttpInterceptionDump.findById(req.params.id) | ||
.then(httpImterceptionDump => { | ||
//Find associated http dumps with this http interception | ||
HttpDump.find({ | ||
'_id': { | ||
$in: [ | ||
mongoose.Types.ObjectId(httpImterceptionDump.originalRequestDumpId), | ||
mongoose.Types.ObjectId(httpImterceptionDump.forwardedRequestDumpId) | ||
] | ||
} | ||
}, function(err, docs){ | ||
if(err){ | ||
console.log(err) | ||
res.send("Unable to load http inspection dumps " + err) | ||
}else{ | ||
//render view | ||
res.render('httpinterceptionsdumps/inspect', { | ||
httpImterceptionDump : httpImterceptionDump, | ||
originalRequestDump : docs[0], | ||
forwardedRequestDump : docs[1] | ||
}); | ||
} | ||
}); | ||
}) | ||
.catch(err => { | ||
console.log(err) | ||
res.send("Unable to retrieve http interception dump" + err) | ||
}) | ||
}); | ||
|
||
module.exports = router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
<div class="card mb-3"> | ||
<div class="card-header container"> | ||
<div class="row"> | ||
<div class="col-sm-6"> | ||
<h4><span class="badge badge-secondary">{{httpImterceptionDump.method}}</span> | ||
({{httpImterceptionDump.fromProtocol}} -> {{httpImterceptionDump.toProtocol}}) </h4> | ||
</div> | ||
<div class="col-sm-6"> | ||
<p class="text-right"><small>{{httpImterceptionDump.payloadSize}} bytes</small></p> | ||
</div> | ||
</div> | ||
<p><small>{{httpImterceptionDump.fromIp}} -> {{httpImterceptionDump.toHost}}</small></p> | ||
<p class="text-left text-secondary"><small>{{httpImterceptionDump.date}}</small></p> | ||
</div> | ||
|
||
<ul class="nav nav-tabs" role="tablist"> | ||
<li class="nav-item"> | ||
<a class="nav-link active" role="tab" data-toggle="tab" aria-controls="originalRequest" aria-selected="true" | ||
href="#originalRequest">Original Request</a> | ||
</li> | ||
<li class="nav-item"> | ||
<a class="nav-link" role="tab" data-toggle="tab" aria-controls="forwadedRequest" aria-selected="false" href="#forwadedRequest">Forwaded | ||
Request</a> | ||
</li> | ||
</ul> | ||
|
||
<div class="tab-content"> | ||
<div id="originalRequest" class="tab-pane fade show active"> | ||
<!-- Display area for original request --> | ||
<div class="card-body"> | ||
<table class="table table-hover"> | ||
<thead> | ||
<tr> | ||
<th>HTTP Request Header</th> | ||
<th>Value</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{{#each originalRequestDump.headers}} | ||
<tr> | ||
<td><small><mark>{{key}}</mark></small></td> | ||
<td><small>{{value}}</small></td> | ||
</tr> | ||
{{/each}} | ||
</tbody> | ||
</table> | ||
</div> | ||
{{#if originalRequestDump.body.length}} | ||
<div class="card-body"> | ||
<div class="d-inline-flex p-2"> | ||
<a href="/reception/download/requestpayload/{{originalRequestDump._id}}" target="_blank" class="btn btn-primary"> | ||
<span class="fas fa-download" aria-hidden="true"></span> Download</a> | ||
</div> | ||
<div class="d-inline-flex p-2"> | ||
<p class="h6 card-title">Request payload size : {{originalRequestDump.body.length}} bytes</p> | ||
</div> | ||
</div> | ||
{{/if}} | ||
<div class="card-body"> | ||
<table class="table table-hover"> | ||
<thead> | ||
<tr> | ||
<th>HTTP Response Header</th> | ||
<th>Value</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{{#each originalRequestDump.responseHeaders}} | ||
<tr> | ||
<td><small><mark>{{key}}</mark></small></td> | ||
<td><small>{{value}}</small></td> | ||
</tr> | ||
{{/each}} | ||
</tbody> | ||
</table> | ||
</div> | ||
{{#if originalRequestDump.responseBody.length}} | ||
<div class="card-body"> | ||
<div class="d-inline-flex p-2"> | ||
<a href="/reception/download/responsepayload/{{originalRequestDump._id}}" target="_blank" class="btn btn-primary"> | ||
<span class="fas fa-download" aria-hidden="true"></span> Download</a> | ||
</div> | ||
<div class="d-inline-flex p-2"> | ||
<p class="h6 card-title">Response payload size : {{originalRequestDump.responseBody.length}} bytes</p> | ||
</div> | ||
</div> | ||
{{/if}} | ||
<!-- End of the display area for original request--> | ||
</div> | ||
<div id="forwadedRequest" class="tab-pane fade"> | ||
<!-- Area for displaying forwaded http request--> | ||
<div class="card-body"> | ||
<table class="table table-hover"> | ||
<thead> | ||
<tr> | ||
<th>HTTP Request Header</th> | ||
<th>Value</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{{#each forwardedRequestDump.headers}} | ||
<tr> | ||
<td><small><mark>{{key}}</mark></small></td> | ||
<td><small>{{value}}</small></td> | ||
</tr> | ||
{{/each}} | ||
</tbody> | ||
</table> | ||
</div> | ||
{{#if forwardedRequestDump.body.length}} | ||
<div class="card-body"> | ||
<div class="d-inline-flex p-2"> | ||
<a href="/reception/download/requestpayload/{{forwardedRequestDump._id}}" target="_blank" class="btn btn-primary"> | ||
<span class="fas fa-download" aria-hidden="true"></span> Download</a> | ||
</div> | ||
<div class="d-inline-flex p-2"> | ||
<p class="h6 card-title">Request payload size : {{forwardedRequestDump.body.length}} bytes</p> | ||
</div> | ||
</div> | ||
{{/if}} | ||
<div class="card-body"> | ||
<table class="table table-hover"> | ||
<thead> | ||
<tr> | ||
<th>HTTP Response Header</th> | ||
<th>Value</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{{#each forwardedRequestDump.responseHeaders}} | ||
<tr> | ||
<td><small><mark>{{key}}</mark></small></td> | ||
<td><small>{{value}}</small></td> | ||
</tr> | ||
{{/each}} | ||
</tbody> | ||
</table> | ||
</div> | ||
{{#if forwardedRequestDump.responseBody.length}} | ||
<div class="card-body"> | ||
<div class="d-inline-flex p-2"> | ||
<a href="/reception/download/responsepayload/{{forwardedRequestDump._id}}" target="_blank" class="btn btn-primary"> | ||
<span class="fas fa-download" aria-hidden="true"></span> Download</a> | ||
</div> | ||
<div class="d-inline-flex p-2"> | ||
<p class="h6 card-title">Response payload size : {{forwardedRequestDump.responseBody.length}} bytes</p> | ||
</div> | ||
</div> | ||
{{/if}} | ||
<!-- End of the area for displaying forwaded http request--> | ||
</div> | ||
</div> | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters