Sha256: 825a693b2893fd0e1b5c63e04d81770e87273da21816e2b1e337cbd7966dda71

Contents?: true

Size: 1.03 KB

Versions: 8

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

module ConvenientService
  module Examples
    module Standard
      module RequestParams
        module Utils
          module HTTP
            module Request
              ##
              # TODO: Specs.
              #
              class ParsePath < Support::Command
                attr_reader :http_string

                def initialize(http_string:)
                  @http_string = http_string
                end

                ##
                # - https://stackoverflow.com/a/17599778/12201472
                # - https://github.com/ruby/webrick/blob/v1.7.0/lib/webrick/httprequest.rb
                #
                def call
                  webrick_request = ::WEBrick::HTTPRequest.new(::WEBrick::Config::HTTP)

                  webrick_request.parse(::StringIO.new(http_string))

                  webrick_request.path
                rescue ::WEBrick::HTTPStatus::BadRequest
                  nil
                end
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
convenient_service-0.12.0 lib/convenient_service/examples/standard/request_params/utils/http/request/parse_path.rb
convenient_service-0.11.0 lib/convenient_service/examples/standard/request_params/utils/http/request/parse_path.rb
convenient_service-0.10.1 lib/convenient_service/examples/standard/request_params/utils/http/request/parse_path.rb
convenient_service-0.10.0 lib/convenient_service/examples/standard/request_params/utils/http/request/parse_path.rb
convenient_service-0.9.0 lib/convenient_service/examples/standard/request_params/utils/http/request/parse_path.rb
convenient_service-0.8.0 lib/convenient_service/examples/standard/request_params/utils/http/request/parse_path.rb
convenient_service-0.7.0 lib/convenient_service/examples/standard/request_params/utils/http/request/parse_path.rb
convenient_service-0.6.0 lib/convenient_service/examples/standard/request_params/utils/http/request/parse_path.rb