Skip to content

AFHTTPSession#delete attempts to call private method #118

@tmillican

Description

@tmillican

I'm attempting to upgrade an app from afmotion 2.6.1 to 3.0, and I've run into an issue.

I have several calls like:

client.delete('some_url', params: { id: 3 }).do #etc

Which result in this crash:

2021-06-17 16:17:24.503 MyApp[34796:143989439] *** Terminating app due to uncaught exception 'NoMethodError',
reason: '/usr/local/var/rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/afmotion-3.0/lib/afmotion/client_shared.rb:81:
in `create_task:': private method `DELETE:parameters:headers:progress:success:failure:' called for #<AFHTTPSessionManager:0x600003d06a30> (NoMethodError)

Note: I have an unrelated issue with RM that's causing incorrect source locations to be reported for this project, but looking at the #create_task method, I can see this is where the call is actually dispatched to AFHTTPSessionManager.DELETE

Here is the full context of that method:

def create_task(http_method, path, options = {}, &callback)
  parameters = options.fetch(:params, {})
  headers = options.fetch(:headers, {})
  progress = options[:progress_block]

  method_signature = "#{http_method.to_s.upcase}:parameters:headers:progress:success:failure"
  success = success_block_for_http_method(http_method, callback)
  failure = failure_block(callback)
  method_and_args = [method_signature, path, parameters, headers, progress, success, failure]

  # HEAD doesn't take a progress arg
  if http_method.to_s.upcase == "HEAD"
    method_signature.gsub!("progress:", "")
    method_and_args.delete_at(4)
  end

  self.public_send(*method_and_args).   # <-- crashes here
end

I might be missing something, but from my reading of AFNetworking/AFHTTPSessionManager.h, it appears that HEAD is not the only exception for the progress parameter. In appears that only GET and POST publicly accept it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions