Skip to content

Commit

Permalink
Rename LLHttp::Parser#method to LLHttp::Parser#method_name
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanp committed Dec 31, 2020
1 parent 461cdae commit 12e37c6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/llhttp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def content_length
self[:content_length]
end

def request_method
def method_name
LLHttp.llhttp_method_name(self[:method]).read_string
end

Expand Down
8 changes: 2 additions & 6 deletions lib/llhttp/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module LLHttp
# Introspection
#
# * `LLHttp::Parser#content_length` returns the content length of the current request.
# * `LLHttp::Parser#method` returns the method of the current response.
# * `LLHttp::Parser#method_name` returns the method of the current response.
# * `LLHttp::Parser#status_code` returns the status code of the current response.
# * `LLHttp::Parser#keep_alive?` returns `true` if there might be more messages.
#
Expand All @@ -32,7 +32,7 @@ module LLHttp
#
class Parser
extend Forwardable
def_delegators :@instance, :parse, :<<, :content_length, :status_code, :keep_alive?
def_delegators :@instance, :parse, :<<, :content_length, :method_name, :status_code, :keep_alive?

LLHTTP_TYPES = {both: 0, request: 1, response: 2}.freeze

Expand All @@ -48,9 +48,5 @@ def initialize(delegate, type: :both)
def finish
LLHttp.llhttp_finish(@instance)
end

def method
@instance.request_method
end
end
end
6 changes: 3 additions & 3 deletions spec/integration/parser/request_parsing/introspection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@ def on_headers_complete
end
end

describe "method" do
describe "method_name" do
let(:extension) {
proc {
def on_headers_complete
@context.instance_variable_set(:@method, @context.instance.method)
@context.instance_variable_set(:@method_name, @context.instance.method_name)
end
}
}

it "returns the content" do
parse

expect(@method).to eq("GET")
expect(@method_name).to eq("GET")
end
end

Expand Down

0 comments on commit 12e37c6

Please sign in to comment.