Method: Browser::HTTP::Response#binary

Defined in:
opal/browser/http/response.rb

#binaryBinary (readonly)

Returns the response body as binary.

Returns:

  • (Binary)

    the response body as binary



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'opal/browser/http/response.rb', line 98

def binary
  return unless request.binary?

  if Buffer.supported?
    %x{
      var result = #@native.response;

      if (!result) {
        return nil;
      }
    }

    Binary.new(Buffer.new(`result`))
  else
    return unless text

    Binary.new(text)
  end
end