Exception: OpenReceive::Server::UnsupportedMediaTypeError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/openreceive/server/errors.rb

Overview

415 — the body-bearing routes accept application/json only. This is the CSRF-equivalent on cookie-authenticated mounts: a cross-site HTML form cannot set a JSON content type, and a cross-origin fetch that does is non-simple (CORS-preflighted, which the library never grants), so a forgery can never reach authorize with the victim's session. Rejected before authorize, like the body cap. Mirrors the JS handler.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = "Request content type must be application/json.") ⇒ UnsupportedMediaTypeError

Returns a new instance of UnsupportedMediaTypeError.



130
131
132
133
134
# File 'lib/openreceive/server/errors.rb', line 130

def initialize(message = "Request content type must be application/json.")
  super(message)
  @status = 415
  @code = "INVALID_REQUEST"
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



128
129
130
# File 'lib/openreceive/server/errors.rb', line 128

def code
  @code
end

#statusObject (readonly)

Returns the value of attribute status.



128
129
130
# File 'lib/openreceive/server/errors.rb', line 128

def status
  @status
end