From bb58d224e7a2500502c3ebc31fe198ae98487a34 Mon Sep 17 00:00:00 2001 From: Jorge Canizales Date: Thu, 19 Mar 2015 00:31:36 -0700 Subject: Removes scheme before passing to C layer --- src/objective-c/GRPCClient/private/GRPCChannel.m | 3 +++ src/objective-c/examples/Sample/Sample/ViewController.m | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'src') 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 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]; -- cgit v1.2.3