diff options
-rw-r--r-- | console/bridge.go | 9 | ||||
-rw-r--r-- | rpc/http.go | 5 |
2 files changed, 11 insertions, 3 deletions
diff --git a/console/bridge.go b/console/bridge.go index 6db54eb21..75be68188 100644 --- a/console/bridge.go +++ b/console/bridge.go @@ -20,6 +20,7 @@ import ( "encoding/json" "fmt" "io" + "strings" "time" "github.com/ethereum/go-ethereum/log" @@ -240,17 +241,19 @@ func (b *bridge) Send(call otto.FunctionCall) (response otto.Value) { throwJSException(err.Error()) } var ( - rawReq = []byte(reqVal.String()) + rawReq = reqVal.String() + dec = json.NewDecoder(strings.NewReader(rawReq)) reqs []jsonrpcCall batch bool ) + dec.UseNumber() // avoid float64s if rawReq[0] == '[' { batch = true - json.Unmarshal(rawReq, &reqs) + dec.Decode(&reqs) } else { batch = false reqs = make([]jsonrpcCall, 1) - json.Unmarshal(rawReq, &reqs[0]) + dec.Decode(&reqs[0]) } // Execute the requests. diff --git a/rpc/http.go b/rpc/http.go index 022f9ce8f..6bab02ab6 100644 --- a/rpc/http.go +++ b/rpc/http.go @@ -162,6 +162,11 @@ func (srv *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { } func newCorsHandler(srv *Server, allowedOrigins []string) http.Handler { + // disable CORS support if user has not specified a custom CORS configuration + if len(allowedOrigins) == 0 { + return srv + } + c := cors.New(cors.Options{ AllowedOrigins: allowedOrigins, AllowedMethods: []string{"POST", "GET"}, |