Skip to content

[Obj-C] Added ability to access HTTP Response headers #1189

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

MrMatthewDavis
Copy link
Contributor

  • Added a property on the ApiClient class that is set before any operation's completionBlock. This allows access to the HTTP response headers by calling .apiClient.HTTPResponseHeaders in any of the API-bodies' completion blocks.
    • Note: It is recommended to only have one ApiClient per thread to ensure that there is no concurrency issues with the HTTPResponseHeaders property across multiple threads.
  • Also added a +sharedAPI class method on the API-Body classes that allows quick initialization of a singleton API instance. I added this because calling +apiWithHeader:key: would not actually add the header and key values unless the singleton was previously nil, and it was the only way to retrieve an existing singleton instance (i.e. if I wanted to access the singleton multiple times, I would have to call +apiWithHeader:key: each time, but the values I passed in for the header and key would only be set the first time, and ignored on each subsequent call). This makes it easier to access the singleton, and also makes it more clear that +apiWithHeader:key: is designed to initialize a new API instance, and not retrieve an existing one. In order to add a header to an existing singleton instance, call [[SWGExampleApi sharedAPI] addHeader:@"exampleHeader" forKey:@"exampleKey"];

Matthew Davis added 2 commits September 3, 2015 12:18
…ed a +sharedAPI class method for easy initialization of an API class without passing headers
@wing328
Copy link
Contributor

wing328 commented Sep 4, 2015

@mad102190 thanks for the PR to provide status code and HTTP header via ApiClient (similar to C# and Java). Integration test results look good:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 28.742 s
[INFO] Finished at: 2015-09-04T16:38:54+08:00
[INFO] Final Memory: 11M/245M
[INFO] ------------------------------------------------------------------------

wing328 added a commit that referenced this pull request Sep 4, 2015
[Obj-C] Added ability to access HTTP Response headers
@wing328 wing328 merged commit 2e30a3a into swagger-api:master Sep 4, 2015
@fehguy fehguy modified the milestone: v2.1.4 Oct 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants