Get POST parameter from NSURLRequest

Is it possible to get the value of the POST parameter from NSURLRequest in the method;

-(BOOL) webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType 

So how is this done?

+4
source share
2 answers

This should be possible using the NSURLProtocol class method:

 + (id)propertyForKey:(NSString *)key inRequest:(NSURLRequest *)request 

So, if you have a property named "place", you can try the following:

 [NSURLProtocol propertyForKey:@"place" inRequest:myRequestObject] 

[EDIT] If you want to get all the properties, I think you should use - (NSData *)HTTPBody from NSURLRequest , and then analyze the property names / values โ€‹โ€‹yourself. There should be no problems with urldecode and RegEx.

+3
source
  NSURLRequest *request = ... NSError *error = nil; NSDictionary *parameters = [NSJSONSerialization JSONObjectWithData:[request HTTPBody] options:0 error:&error]; 
0
source

Source: https://habr.com/ru/post/1347516/


All Articles