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

Set accepted header types #19

Closed
holgersindbaek opened this issue Jun 22, 2013 · 2 comments
Closed

Set accepted header types #19

holgersindbaek opened this issue Jun 22, 2013 · 2 comments

Comments

@holgersindbaek
Copy link

How would you go about this in afmotion?

I'm querying for a plist like this:

  AFMotion::PLIST.get("http://#{@signup_input.text}.uninkd.com/existence.plist") do |result|
    if result.success?
      ap "Success"
    elsif result.failure?
      ap "result.failure"
    end
  end

It's being returned as a failure all the time though, since it's not a "application/x-plist" on the server, but a "text/plist".

How can I set the accepted headers on the request?

@clayallsopp
Copy link
Collaborator

AFMotion is a wrapper around AFNetworking, so most questions can be answered by researching how something is achieved with AFNetworking.

In this case, patch AFPropertyListRequestOperation like so:

class AFPropertyListRequestOperation
  def self.acceptableContentTypes
    NSSet.setWithArray ["application/x-plist", "text/plist"]
  end
end

@holgersindbaek
Copy link
Author

Thanks for the quick reply.

Think I'm gonna end up doing it like this:

  client = AFMotion::Client.build("http://#{@signup_input.text}.uninkd.com/") do
    header "Accept", "application/x-plist"
    operation :plist
  end

  client.get("existence") do |result|
    if result.success?
      ap "Success"
    elsif result.failure?
      ap "result.failure"
    end
  end

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

No branches or pull requests

2 participants