Class: MockServer::HttpError

Inherits:
Object
  • Object
show all
Defined in:
lib/mockserver/models.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(drop_connection: nil, response_bytes: nil, stream_error: nil, delay: nil, primary: nil) ⇒ HttpError

Returns a new instance of HttpError.



1001
1002
1003
1004
1005
1006
1007
# File 'lib/mockserver/models.rb', line 1001

def initialize(drop_connection: nil, response_bytes: nil, stream_error: nil, delay: nil, primary: nil)
  @drop_connection = drop_connection
  @response_bytes = response_bytes
  @stream_error = stream_error
  @delay = delay
  @primary = primary
end

Instance Attribute Details

#delayObject

stream_error: reset the matched request stream with this error code (HTTP/2 RST_STREAM / HTTP/3 RESET_STREAM) instead of returning a response; HTTP/1.1 has no stream concept so this falls back to dropping the connection. Takes precedence over drop_connection when both are set.



999
1000
1001
# File 'lib/mockserver/models.rb', line 999

def delay
  @delay
end

#drop_connectionObject

stream_error: reset the matched request stream with this error code (HTTP/2 RST_STREAM / HTTP/3 RESET_STREAM) instead of returning a response; HTTP/1.1 has no stream concept so this falls back to dropping the connection. Takes precedence over drop_connection when both are set.



999
1000
1001
# File 'lib/mockserver/models.rb', line 999

def drop_connection
  @drop_connection
end

#primaryObject

stream_error: reset the matched request stream with this error code (HTTP/2 RST_STREAM / HTTP/3 RESET_STREAM) instead of returning a response; HTTP/1.1 has no stream concept so this falls back to dropping the connection. Takes precedence over drop_connection when both are set.



999
1000
1001
# File 'lib/mockserver/models.rb', line 999

def primary
  @primary
end

#response_bytesObject

stream_error: reset the matched request stream with this error code (HTTP/2 RST_STREAM / HTTP/3 RESET_STREAM) instead of returning a response; HTTP/1.1 has no stream concept so this falls back to dropping the connection. Takes precedence over drop_connection when both are set.



999
1000
1001
# File 'lib/mockserver/models.rb', line 999

def response_bytes
  @response_bytes
end

#stream_errorObject

stream_error: reset the matched request stream with this error code (HTTP/2 RST_STREAM / HTTP/3 RESET_STREAM) instead of returning a response; HTTP/1.1 has no stream concept so this falls back to dropping the connection. Takes precedence over drop_connection when both are set.



999
1000
1001
# File 'lib/mockserver/models.rb', line 999

def stream_error
  @stream_error
end

Class Method Details

.errorObject



1031
1032
1033
# File 'lib/mockserver/models.rb', line 1031

def self.error
  new
end

.from_hash(data) ⇒ Object



1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
# File 'lib/mockserver/models.rb', line 1019

def self.from_hash(data)
  return nil if data.nil?

  new(
    drop_connection: data['dropConnection'],
    response_bytes:  data['responseBytes'],
    stream_error:    data['streamError'],
    delay:           Delay.from_hash(data['delay']),
    primary:         data['primary']
  )
end

Instance Method Details

#to_hObject



1009
1010
1011
1012
1013
1014
1015
1016
1017
# File 'lib/mockserver/models.rb', line 1009

def to_h
  MockServer.strip_none({
    'dropConnection' => @drop_connection,
    'responseBytes'  => @response_bytes,
    'streamError'    => @stream_error,
    'delay'          => @delay&.to_h,
    'primary'        => @primary
  })
end