managegogl.blogg.se

Interceptor for postman for mac
Interceptor for postman for mac




interceptor for postman for mac

The last NSURLProtocol abstract method it’s the stopLoading, and simply stops loading the current request by calling the connection cancel method. Notice that I simply make a mutable copy of the original request before adding the new header and then set the Protocol connection by updating the previously changed request. As you can see below, this is the right place to add a specific header to be sent to the server.

interceptor for postman for mac

It is called every time a request is made and starts loading the request. The next abstract method is the startLoading. This ensures that the protocol classes guarantees that the same input request always yields the same canonical form. The first one is the canInitWithRequest and as you can see by the image below, I just want to intercept all the HTTPS requests.Īfter validating the URL request, the next step is to add the canonicalRequestForRequest abstract method. You need to implement several NSURLProtocol abstract methods in order to make sure that the request flow works properly. The Apple Foundation Framework provides the NSURLProtocol abstract class which our interceptor will extend. This project has two implementation phases:įirst of all, why do you need to implement a Protocol? To intercept any request we need an entity or a class that helps us handle the loading of protocol-specific URL data. I started by creating a simple iOS application, which is pretty much a generic Objective-C App that makes a simple GET request to the postman-echo. There you can learn the basics and get detailed information about all the classes, objects and required methods during the implementation process. Before you go any deeper, I highly recommend taking a look at the Apple Developer Documentation. In order to implement an HTTP requests interceptor you just need to create your own Protocol, based on the Foundation Framework, the NSURLProtocol.






Interceptor for postman for mac