natescherer/apn_on_rails — pull request #1 by andlima (2011-12-14 17:26:08+00:00)
Title: Prevent ASCII-related error when json is bigger than 255 chars.

On `message_for_sending`, when `json` is bigger than 255 chars, trying to do `#{json.length.chr}` on the construction of `message` will result on the following error:

incompatible character encodings: ASCII-8BIT and UTF-8

This would happen before detecting that the payload is too large, which was done after the message was actually created. This patch makes the `ExceededMessageSizeError` exception to be raised instead of the ASCII stuff when this situation happens.

PS: This happens, for example, when the notification has a too large `custom_properties` hash.