3

I implemented a WebPolicyDelegate and the ...decidePolicyForNavigationAction:... method.
It works fine, I get among other things the HTTP method [GET|POST] but what I can't find is the actual GET and POST data. Where or how should I get it?

Charles
  • 48,924
  • 13
  • 96
  • 136
Petruza
  • 10,275
  • 24
  • 74
  • 121

1 Answers1

1

How about:

NSString *queryString = [[request URL] query];
NSData *postData = [request HTTPBody];

GET data is just the query string of the URI.

paulmelnikow
  • 16,036
  • 6
  • 56
  • 110
  • Ok, so I have to parse that data? isn't there any way to get something like an NSDictionary with the GET or POST keys and their values? – Petruza Aug 17 '11 at 03:16
  • For the query string, some previous responses: http://stackoverflow.com/questions/3997976/parse-nsurl-query-property http://stackoverflow.com/questions/1967399/parse-nsurl-path-and-query-iphoneos http://stackoverflow.com/questions/1626876/parse-query-string-into-a-structured-nsdictionary – paulmelnikow Aug 17 '11 at 04:29
  • 1
    For post, looks like you can get the equivalent query string with `[[NSString alloc] initWithData:[request HTTPBody] encoding:NSUTF8StringEncoding]`. See comments on the accepted answer to this question: http://stackoverflow.com/questions/6148900/append-data-to-a-post-nsurlrequest – paulmelnikow Aug 17 '11 at 04:36