-
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.
- Loading branch information
Showing
4 changed files
with
94 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[16:44 01/06/2015] | ||
|
||
URI: | ||
localhost:1337/keeex?action=""&username=""&digest=""&path="" |
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 @@ | ||
THONG |
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,52 @@ | ||
var http = require('http'); | ||
var url = require('url'); | ||
var fs = require('fs'); | ||
|
||
var server = http.createServer(function(request, response) { | ||
|
||
//parse url and respond base on action | ||
var query = url.parse(request.url, true).query; | ||
var action = query.action; | ||
var path = query.path; | ||
|
||
response.writeHead(200); | ||
if (action=="keeexit") | ||
{ | ||
|
||
if (!path && fs.existsSync(path)) | ||
{ | ||
response.writeHead(200); | ||
/*TODO | ||
return the path to the keeexed file or its content | ||
*/ | ||
} | ||
else | ||
{ | ||
//return bad request | ||
response.writeHead(400); | ||
} | ||
} | ||
else if (action=="verify") | ||
{ | ||
if (!path && fs.existsSync(path)) | ||
{ | ||
response.writeHead(200); | ||
/*TODO | ||
return whether the file is in the lastest version | ||
*/ | ||
} | ||
else | ||
{ | ||
//return bad request | ||
response.writeHead(400); | ||
} | ||
} | ||
else | ||
{ | ||
//action not supported | ||
response.writeHead(404); | ||
} | ||
response.end(); | ||
|
||
}).listen(3000, '127.0.0.1'); | ||
|
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,37 @@ | ||
var http = require('http'); | ||
|
||
|
||
function getStatusCode(request, callback) { | ||
var options = { | ||
host: "127.0.0.1", | ||
port: 3000, | ||
path: request, | ||
headers: { | ||
Host: request | ||
} | ||
}; | ||
http.get(options, function(response) { | ||
callback(response.statusCode); | ||
}); | ||
} | ||
|
||
function proceedReturnCode(code) | ||
{ | ||
switch (code) | ||
{ | ||
case 200: | ||
//request success | ||
break; | ||
case 400: | ||
//bad param | ||
break; | ||
case 404: | ||
//action not found | ||
break; | ||
} | ||
console.log(code); | ||
} | ||
|
||
var action = "keeexit"; | ||
var path = "E:\\test\\image.bmp"; | ||
getStatusCode("/keeex?action="+action+"&path="+path, proceedReturnCode); |