我在 gcdwebserver 上工作,我正在向 gcdwebserver 发送 post 请求,也发送一些参数,但是在 addhandlermatchblock 中没有得到查询参数,请回复
代码:
NSString * postString=@"name=ram&age=20";
NSURLSession * session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
NSURL * url=[NSURL URLWithString:@"http://127.0.0.1:8080/index.html"];
NSMutableURLRequest * request=[NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"GET"];
[request setHTTPBody:[postString dataUsingEncoding:NSUTF8StringEncoding]];
[webServer addHandlerWithMatchBlock:^GCDWebServerRequest *(NSString* requestMethod, NSURL* requestURL, NSDictionary* requestHeaders, NSString* urlPath, NSDictionary* urlQuery) {
if (![requestMethod isEqualToString:@"GET"]) {
return nil;
}
return [[GCDWebServerRequest alloc] initWithMethod:requestMethod url:requestURL headers:requestHeaders path:urlPath query:urlQuery];
} processBlock:^GCDWebServerResponse *(GCDWebServerRequest* request) {
NSLog(@"coming here get %@",request.urlQuery); // null
GCDWebServerResponse* response = nil;
return response;
}];