Removes scheme before passing to C layer

pull/1341/head
Jorge Canizales 10 years ago
parent ba37a3e525
commit bb58d224e7
  1. 3
      src/objective-c/GRPCClient/private/GRPCChannel.m
  2. 2
      src/objective-c/examples/Sample/Sample/ViewController.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

@ -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];

Loading…
Cancel
Save