aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/objective-c/GRPCClient
diff options
context:
space:
mode:
authorGravatar Jorge Canizales <jcanizales@google.com>2015-03-19 00:31:36 -0700
committerGravatar Jorge Canizales <jcanizales@google.com>2015-04-21 17:58:47 -0700
commitbb58d224e7a2500502c3ebc31fe198ae98487a34 (patch)
treecbb15935a253f90bed10ffae539925097a2048de /src/objective-c/GRPCClient
parentba37a3e525fb2d52aecd174d2a4d7491bcc95764 (diff)
Removes scheme before passing to C layer
Diffstat (limited to 'src/objective-c/GRPCClient')
-rw-r--r--src/objective-c/GRPCClient/private/GRPCChannel.m3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/objective-c/GRPCClient/private/GRPCChannel.m b/src/objective-c/GRPCClient/private/GRPCChannel.m
index 91f2aac40e..2107685d85 100644
--- a/src/objective-c/GRPCClient/private/GRPCChannel.m
+++ b/src/objective-c/GRPCClient/private/GRPCChannel.m
@@ -51,6 +51,7 @@
- (instancetype)initWithHost:(NSString *)host {
if (![host containsString:@"://"]) {
+ // No scheme provided; assume https.
host = [@"https://" stringByAppendingString:host];
}
NSURL *hostURL = [NSURL URLWithString:host];
@@ -58,9 +59,11 @@
[NSException raise:NSInvalidArgumentException format:@"Invalid URL: %@", host];
}
if ([hostURL.scheme isEqualToString:@"https"]) {
+ host = [hostURL.host stringByAppendingString:hostURL.port.stringValue ?: @":443"];
return [[GRPCSecureChannel alloc] initWithHost:host];
}
if ([hostURL.scheme isEqualToString:@"http"]) {
+ host = [hostURL.host stringByAppendingString:hostURL.port.stringValue ?: @":80"];
return [[GRPCUnsecuredChannel alloc] initWithHost:host];
}
[NSException raise:NSInvalidArgumentException