Skip to content
This repository has been archived by the owner on Feb 28, 2018. It is now read-only.

Commit

Permalink
Merge pull request #164 from mvrilo/delete-patch
Browse files Browse the repository at this point in the history
Handle HTTP DELETE requests
  • Loading branch information
evilsocket committed Feb 27, 2016
2 parents c08ae99 + 91f66dd commit 90814fc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lib/bettercap/proxy/stream_logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ def self.log_post( request )
# Log a HTTP ( HTTPS if +is_https+ is true ) stream performed by the +client+
# with the +request+ and +response+ most important informations.
def self.log_http( request, response )
response_s = "( #{response.content_type} )"
response_s = ""
response_s += " ( #{response.content_type} )" unless response.content_type.nil?
request_s = request.to_url( request.post?? nil : @@MAX_REQ_SIZE )
code = response.code.to_s[0]

Expand All @@ -154,7 +155,7 @@ def self.log_http( request, response )
response_s += " [#{response.code}]"
end

Logger.raw "[#{self.addr2s(request.client)}] #{request.method.light_blue} #{request_s} #{response_s}"
Logger.raw "[#{self.addr2s(request.client)}] #{request.method.light_blue} #{request_s}#{response_s}"
# Log post body if the POST sniffer is enabled.
if Context.get.post_sniffer_enabled?
self.log_post( request )
Expand Down
9 changes: 8 additions & 1 deletion lib/bettercap/proxy/streamer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def handle( request, client, redirects = 0 )
response = r
end

if response.textual?
if response.textual? or request.method == 'DELETE'
StreamLogger.log_http( request, response )
else
Logger.debug "[#{request.client}] -> #{request.to_url} [#{response.code}]"
Expand Down Expand Up @@ -187,6 +187,13 @@ def do_HEAD(req, res)
end
end

# Handle a DELETE request, +req+ is the request object and +res+ the response.
def do_DELETE(req, res)
perform_proxy_request(req, res) do |http, path, header|
http.delete(path, header)
end
end

# Handle a POST request, +req+ is the request object and +res+ the response.
def do_POST(req, res)
perform_proxy_request(req, res) do |http, path, header|
Expand Down

0 comments on commit 90814fc

Please sign in to comment.