mirror of
https://github.com/lloeki/nanoserve.git
synced 2025-12-06 11:14:40 +01:00
Implement request host, path and content_type access
This commit is contained in:
parent
dd5001cb7c
commit
66a2a20663
1 changed files with 12 additions and 0 deletions
|
|
@ -98,6 +98,14 @@ module NanoServe
|
||||||
@body = +''.encode('ASCII-8BIT')
|
@body = +''.encode('ASCII-8BIT')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def host
|
||||||
|
@headers['host']
|
||||||
|
end
|
||||||
|
|
||||||
|
def path
|
||||||
|
@uri.path
|
||||||
|
end
|
||||||
|
|
||||||
def params
|
def params
|
||||||
Hash[*@uri.query.split('&').map { |kv| kv.split('=') }.flatten]
|
Hash[*@uri.query.split('&').map { |kv| kv.split('=') }.flatten]
|
||||||
end
|
end
|
||||||
|
|
@ -132,6 +140,10 @@ module NanoServe
|
||||||
@headers.key?('content-length')
|
@headers.key?('content-length')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def content_type
|
||||||
|
@headers['content-type']
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
REQ_RE = %r{(?<method>[A-Z]+)\s+(?<path>\S+)\s+(?<version>HTTP/\d+.\d+)$}
|
REQ_RE = %r{(?<method>[A-Z]+)\s+(?<path>\S+)\s+(?<version>HTTP/\d+.\d+)$}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue