Projects

Ticket #689 (closed defect: fixed)

Opened 21 months ago

Last modified 21 months ago

Net::HTTP.post_form() is broken.

Reported by: rob@… Owned by: lsansonetti@…
Priority: blocker Milestone: MacRuby 0.7
Component: MacRuby Keywords:
Cc: bricollins@…

Description

I'm running the latest nightly(05/05/2010), to reproduce:

require 'net/http'
Net::HTTP.post_form(URI.parse('http://www.google.com/foobar', { :foo => 'bar' })

# ... Produces:
ArgumentError: method `force_encoding:' does not work on NSStrings

Thanks.

Attachments

0001-fix-urlencoding-in-net-http.patch Download (0.9 KB) - added by bricollins@… 21 months ago.
0002-fix-urlencoding-in-net-http.patch Download (0.7 KB) - added by bricollins@… 21 months ago.

Change History

in reply to: ↑ description   Changed 21 months ago by rob@…

Replying to rob@…:

I'm running the latest nightly(05/05/2010), to reproduce: {{{ require 'net/http' Net::HTTP.post_form(URI.parse(' http://www.google.com/foobar', { :foo => 'bar' }) # ... Produces: ArgumentError: method `force_encoding:' does not work on NSStrings }}} Thanks.

Syntax error in the last demo, should be:

require 'net/http'
Net::HTTP.post_form(URI.parse('http://www.google.com/foobar'), { :foo => 'bar' })

# ... Produces:
ArgumentError: method `force_encoding:' does not work on NSStrings

Changed 21 months ago by bricollins@…

  Changed 21 months ago by bricollins@…

I've attached a patch, it uses the native NSString percent escaping instead of that ugly regex. However we don't know if NSUTF8StringEncoding is defined when net/http is required so there is an ugly one liner to define it as 4 otherwise. I've no doubt lsansonetti will figure out a better way.

  Changed 21 months ago by bricollins@…

  • cc bricollins@… added

Cc Me!

Changed 21 months ago by bricollins@…

  Changed 21 months ago by bricollins@…

Better version uploaded

  Changed 21 months ago by lsansonetti@…

  • status changed from new to closed
  • resolution set to fixed
  • milestone set to MacRuby 0.7

This was simply a bug in net/http.rb that was fixed upstream in 1.9, #to_s wasn't called on keys on the given hash. I backported the latest version in r4083 and the snippet now works.

Note: See TracTickets for help on using tickets.