Created
February 19, 2012 21:19
-
-
Save dartov/1865846 to your computer and use it in GitHub Desktop.
Simple HTTP dumping script for Greasyspoon and Mongo
This file contains hidden or 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
//------------------------------------------------------------------- | |
// ==ServerScript== | |
// @name dump_http | |
// @status on | |
// @description Simple http dumping script | |
// @include .* | |
// @exclude | |
// @responsecode 200 | |
// ==/ServerScript== | |
// -------------------------------------------------------------------- | |
// Note: use httpMessage object methods to manipulate HTTP Message | |
// use debug(String s) method to trace items in service log (with log level >=FINE) | |
// --------------- | |
import com.mongodb.Mongo; | |
import com.mongodb.DB; | |
import com.mongodb.DBCollection; | |
import com.mongodb.BasicDBObject; | |
import com.mongodb.DBObject; | |
// --------------- | |
public void main(HttpMessage httpMessage){ | |
try{ | |
Mongo m = new Mongo("localhost"); | |
DB db = m.getDB("test"); | |
DBCollection coll = db.getCollection("raw_traffic"); | |
BasicDBObject response = new BasicDBObject(); | |
response.put("requestHeader",httpMessage.getRequestHeaders()); | |
response.put("responseHeader",httpMessage.getResponseHeaders()); | |
response.put("responseBody",httpMessage.getBody()); | |
coll.insert(response); | |
}catch (Exception e){ | |
debug(e.getMessage()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment