-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #162 from buger/input-modifier
Middleware for custom request rewrite logic
- Loading branch information
Showing
36 changed files
with
1,431 additions
and
237 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 |
---|---|---|
|
@@ -4,3 +4,7 @@ | |
*.out | ||
|
||
*.bin | ||
|
||
*.gz | ||
|
||
*.class |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
language: go | ||
go: 1.4.2 | ||
script: sudo -E bash -c "source /etc/profile && eval '$(gimme 1.4.2)' && export GOPATH=$HOME/gopath:$GOPATH && go get && GORACE='halt_on_error=1' go test ./... -v -timeout 15s" | ||
script: sudo -E bash -c "source /etc/profile && eval '$(gimme 1.4.2)' && export GOPATH=$HOME/gopath:$GOPATH && go get && GORACE='halt_on_error=1' go test ./... -v -timeout 60s -race" |
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
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,30 @@ | ||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStreamReader; | ||
|
||
import org.apache.commons.io.IOUtils; | ||
|
||
public class echo { | ||
public static void main(String[] args) { | ||
if(args != null){ | ||
for(String arg : args){ | ||
System.out.println(arg); | ||
} | ||
|
||
} | ||
|
||
BufferedReader stdin = new BufferedReader(new InputStreamReader( | ||
System.in)); | ||
String line = null; | ||
|
||
try { | ||
while ((line = stdin.readLine()) != null) { | ||
|
||
System.out.println(line); | ||
|
||
} | ||
} catch (IOException e) { | ||
IOUtils.closeQuietly(stdin); | ||
} | ||
} | ||
} |
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,15 @@ | ||
#!/usr/bin/env ruby | ||
# encoding: utf-8 | ||
while data = STDIN.gets | ||
next unless data | ||
data = data.chomp | ||
|
||
decoded = [data].pack("H*") | ||
encoded = decoded.unpack("H*").first | ||
|
||
STDOUT.puts encoded | ||
|
||
STDERR.puts "[DEBUG][MIDDLEWARE] Original data: #{data}" | ||
STDERR.puts "[DEBUG][MIDDLEWARE] Decoded request: #{decoded}" | ||
STDERR.puts "[DEBUG][MIDDLEWARE] Encoded data: #{encoded}" | ||
end |
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,42 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# `xxd` utility included into vim-common package | ||
# It allow hex decoding/encoding | ||
|
||
function log { | ||
# Logging to stderr, because stdout/stdin used for data transfer | ||
>&2 echo "[DEBUG][ECHO] $1" | ||
} | ||
|
||
while read line; do | ||
decoded=$(echo -e "$line" | xxd -r -p) | ||
|
||
header=$(echo -e "$decoded" | head -n +1) | ||
payload=$(echo -e "$decoded" | tail -n +2) | ||
|
||
encoded=$(echo -e "$header\n$payload" | xxd -p | tr -d "\\n") | ||
|
||
log "" | ||
log "===================================" | ||
|
||
case ${header:0:1} in | ||
"1") | ||
log "Request type: Request" | ||
;; | ||
"2") | ||
log "Request type: Original Response" | ||
;; | ||
"3") | ||
log "Request type: Replayed Response" | ||
;; | ||
*) | ||
log "Unknown request type $header" | ||
esac | ||
echo "$encoded" | ||
|
||
log "===================================" | ||
|
||
log "Original data: $line" | ||
log "Decoded request: $decoded" | ||
log "Encoded data: $encoded" | ||
done; |
Oops, something went wrong.