Merge pull request #956 from ethcore/cors-option
Changing cors header to be optional
This commit is contained in:
		
						commit
						9b2f545391
					
				
							
								
								
									
										2
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										2
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							| @ -538,7 +538,7 @@ dependencies = [ | ||||
| [[package]] | ||||
| name = "jsonrpc-http-server" | ||||
| version = "5.0.1" | ||||
| source = "git+https://github.com/debris/jsonrpc-http-server.git#239066b94660a1af24c8b2efc16e800f9c7cce18" | ||||
| source = "git+https://github.com/debris/jsonrpc-http-server.git#e728f2e080799b7a62b0b5cf5fa9d4ad65cd8c96" | ||||
| dependencies = [ | ||||
|  "hyper 0.9.0-mio (git+https://github.com/hyperium/hyper?branch=mio)", | ||||
|  "jsonrpc-core 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", | ||||
|  | ||||
| @ -133,8 +133,7 @@ API and Console Options: | ||||
|   --jsonrpc-interface IP   Specify the hostname portion of the JSONRPC API | ||||
|                            server, IP should be an interface's IP address, or | ||||
|                            all (all interfaces) or local [default: local]. | ||||
|   --jsonrpc-cors URL       Specify CORS header for JSON-RPC API responses | ||||
|                            [default: null]. | ||||
|   --jsonrpc-cors URL       Specify CORS header for JSON-RPC API responses. | ||||
|   --jsonrpc-apis APIS      Specify the APIs available through the JSONRPC | ||||
|                            interface. APIS is a comma-delimited list of API | ||||
|                            name. Possible name are web3, eth and net. | ||||
| @ -242,7 +241,7 @@ struct Args { | ||||
| 	flag_jsonrpc: bool, | ||||
| 	flag_jsonrpc_interface: String, | ||||
| 	flag_jsonrpc_port: u16, | ||||
| 	flag_jsonrpc_cors: String, | ||||
| 	flag_jsonrpc_cors: Option<String>, | ||||
| 	flag_jsonrpc_apis: String, | ||||
| 	flag_webapp: bool, | ||||
| 	flag_webapp_port: u16, | ||||
| @ -307,7 +306,7 @@ fn setup_rpc_server( | ||||
| 	secret_store: Arc<AccountService>, | ||||
| 	miner: Arc<Miner>, | ||||
| 	url: &SocketAddr, | ||||
| 	cors_domain: &str, | ||||
| 	cors_domain: Option<String>, | ||||
| 	apis: Vec<&str>, | ||||
| ) -> RpcServer { | ||||
| 	use rpc::v1::*; | ||||
| @ -380,7 +379,7 @@ fn setup_rpc_server( | ||||
| 	_secret_store: Arc<AccountService>, | ||||
| 	_miner: Arc<Miner>, | ||||
| 	_url: &str, | ||||
| 	_cors_domain: &str, | ||||
| 	_cors_domain: Option<String>, | ||||
| 	_apis: Vec<&str>, | ||||
| ) -> ! { | ||||
| 	die!("Your Parity version has been compiled without JSON-RPC support.") | ||||
| @ -713,7 +712,7 @@ impl Configuration { | ||||
| 				self.args.flag_rpcport.unwrap_or(self.args.flag_jsonrpc_port) | ||||
| 			); | ||||
| 			let addr = SocketAddr::from_str(&url).unwrap_or_else(|_| die!("{}: Invalid JSONRPC listen host/port given.", url)); | ||||
| 			let cors_domain = self.args.flag_rpccorsdomain.as_ref().unwrap_or(&self.args.flag_jsonrpc_cors); | ||||
| 			let cors_domain = self.args.flag_jsonrpc_cors.clone().or(self.args.flag_rpccorsdomain.clone()); | ||||
| 
 | ||||
| 			Some(setup_rpc_server( | ||||
| 				service.client(), | ||||
| @ -721,7 +720,7 @@ impl Configuration { | ||||
| 				account_service.clone(), | ||||
| 				miner.clone(), | ||||
| 				&addr, | ||||
| 				&cors_domain, | ||||
| 				cors_domain, | ||||
| 				apis.split(',').collect() | ||||
| 			)) | ||||
| 		} else { | ||||
|  | ||||
| @ -58,8 +58,8 @@ impl RpcServer { | ||||
| 	} | ||||
| 
 | ||||
| 	/// Start server asynchronously and returns result with `Server` handle on success or an error.
 | ||||
| 	pub fn start_http(&self, addr: &SocketAddr, cors_domain: &str) -> Result<Server, RpcServerError> { | ||||
| 	pub fn start_http(&self, addr: &SocketAddr, cors_domain: Option<String>) -> Result<Server, RpcServerError> { | ||||
| 		let cors_domain = cors_domain.to_owned(); | ||||
| 		Server::start(addr, self.handler.clone(), jsonrpc_http_server::AccessControlAllowOrigin::Value(cors_domain)) | ||||
| 		Server::start(addr, self.handler.clone(), cors_domain.map(jsonrpc_http_server::AccessControlAllowOrigin::Value)) | ||||
| 	} | ||||
| } | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user