Sha256: 155dfe03ade8043ba57eb168c73a4e360987cd27f19defe54f47ede716389e99

Contents?: true

Size: 786 Bytes

Versions: 4

Compression:

Stored size: 786 Bytes

Contents

#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require 'webrick'
require 'webrick/httpproxy'
require 'uri'

handler = Proc.new do |req, res|
  puts "=" * 100
  puts req.request_uri.to_s
  puts req.path
  puts res.body.to_s
  if req.path =~ %r{/api/\d+.\d+.\d+/actions.json}
    # server_timeの戻り値を10日先に書き換えています
    body = res.body
    body.gsub!(/\\\"result\\\":\s*(\d+)/){ "\\\"result\\\":%d" % ($1.to_i + 10 * 24 * 60 * 60) }
    body.gsub!(/\"result\":\s*(\d+)/){ "\"result\":%d" % ($1.to_i + 10 * 24 * 60 * 60) }
  end
  puts "-" * 100
end

s = WEBrick::HTTPProxyServer.new(
  :Port => 5000,
  :Logger => WEBrick::Log::new($stdout, WEBrick::Log::DEBUG),
  :ProxyVia => false,
  :ProxyContentHandler => handler
)

Signal.trap('INT'){ s.shutdown }
s.start

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
libgss-0.11.0 bin/cheat_response_proxy
libgss-0.10.0 bin/cheat_response_proxy
libgss-0.9.0 bin/cheat_response_proxy
libgss-0.8.4 bin/cheat_response_proxy