Skip to content
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

Workaround for issue #16 #18

Merged
merged 1 commit into from
Nov 25, 2015
Merged

Workaround for issue #16 #18

merged 1 commit into from
Nov 25, 2015

Conversation

jasoncabot
Copy link
Contributor

NFXBody will now check the NSURLProtocol for if a value is set for the body data.

This is to work around a problem where by the time NSURLProtocol.startLoading is called, the HTTPBody of the request and canonical request will both be nil

If you don't set the NFXBodyData property then it will be ignored and defaulted to the original behaviour of returning NSData()

If you want to log request data you should do something like the following:

if let bodyData = mutableURLRequest.HTTPBody {
  NSURLProtocol.setProperty(bodyData, forKey: "NFXBodyData", inRequest: mutableURLRequest)
}

Wherever you construct your NSMutableURLRequest's (for instance when using Alamofire - in URLRequest of URLRequestConvertible)

See: http://openradar.appspot.com/15993891

…e body data.

This is to work around a problem where by the time NSURLProtocol.startLoading is called, the HTTPBody of the request and canonical request will both be nil

If you don't set the NFXBodyData property then it will be ignored and defaulted to the original behaviour of returning NSData()

If you want to log request data you should do something like the following:

        if let bodyData = mutableURLRequest.HTTPBody {
            NSURLProtocol.setProperty(bodyData, forKey: "NFXBodyData", inRequest: mutableURLRequest)
        }

Wherever you construct your NSMutableURLRequest's (for instance when using Alamofire - in URLRequest of URLRequestConvertible)

See: http://openradar.appspot.com/15993891
@jasoncabot jasoncabot changed the title Workaround for https://github.com/kasketis/netfox/issues/16 Workaround for issue #16 Nov 25, 2015
@kasketis kasketis merged commit c066fe9 into kasketis:master Nov 25, 2015
@kasketis
Copy link
Owner

Awesome work mate! I will add this workaround in the readme file 👍
Thanks for your help :D

@jasoncabot jasoncabot deleted the request_body branch November 26, 2015 08:57
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.

2 participants