aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
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
parentba37a3e525fb2d52aecd174d2a4d7491bcc95764 (diff)
Removes scheme before passing to C layer
Diffstat (limited to 'src')
-rw-r--r--src/objective-c/GRPCClient/private/GRPCChannel.m3
-rw-r--r--src/objective-c/examples/Sample/Sample/ViewController.m2
2 files changed, 4 insertions, 1 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
diff --git a/src/objective-c/examples/Sample/Sample/ViewController.m b/src/objective-c/examples/Sample/Sample/ViewController.m
index 839e181070..99d6df522d 100644
--- a/src/objective-c/examples/Sample/Sample/ViewController.m
+++ b/src/objective-c/examples/Sample/Sample/ViewController.m
@@ -54,7 +54,7 @@
id<GRXWriter> requestsWriter = [GRXWriter writerWithValue:[NSData data]];
- GRPCCall *call = [[GRPCCall alloc] initWithHost:@"grpc-test.sandbox.google.com:443"
+ GRPCCall *call = [[GRPCCall alloc] initWithHost:@"grpc-test.sandbox.google.com"
method:method
requestsWriter:requestsWriter];