-
Notifications
You must be signed in to change notification settings - Fork 1.7k
More CLI settings for IPFS API #4608
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of grumbles.
ipfs/src/lib.rs
Outdated
|
||
pub fn new(cors: Option<Vec<String>>, hosts: Option<Vec<String>>, client: Arc<BlockChainClient>) -> Self { | ||
fn origin_to_header(origin: String) -> AccessControlAllowOrigin { | ||
if origin == "*" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should handle null
as well (file:///
and sandboxed iframes)
ipfs/src/lib.rs
Outdated
pub struct IpfsHandler { | ||
/// Response to send out | ||
out: Out, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why put those new lines? I think I a compact form more.
|
||
cors_domains.iter().any(|domain| match *domain { | ||
AccessControlAllowOrigin::Value(ref allowed) => origin == allowed, | ||
AccessControlAllowOrigin::Any => true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Null
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already fixed, you just can't see it on the diff here (it's one line below).
} | ||
} | ||
|
||
if let Some(cors_header) = cors::get_cors_header(&self.cors_domains, &self.origin) { | ||
res.headers_mut().set(cors_header); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should also send Access-Control-Allow-Methods
, Access-Control-Allow-Headers
and Vary: Origin
headers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Access-Control-Allow-Methods
and Access-Control-Allow-Headers
are only necessary in preflight requests, currently non-GET requests get killed outright so there is no need for them. I've added Vary
.
ipfs/src/lib.rs
Outdated
port: u16, | ||
interface: String, | ||
cors: Option<Vec<String>>, | ||
hosts: Option<Vec<String>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting is odd here.
--ipfs-api-interface
.--ipfs-api-hosts
.--ipfs-api-cors
.Host
orOrigin
header is sent to avoid side effects.parity/configuration.rs
.