File: script.rb

package info (click to toggle)
ruby-protocol-http1 0.14.6-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid
  • size: 264 kB
  • sloc: ruby: 1,146; makefile: 4
file content (36 lines) | stat: -rwxr-xr-x 699 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env ruby
# frozen_string_literal: true

# Released under the MIT License.
# Copyright, 2020-2022, by Samuel Williams.

require 'socket'
require_relative '../../lib/protocol/http1'

def test
	# input, output = Socket.pair(Socket::PF_UNIX, Socket::SOCK_STREAM)
	
	server = Protocol::HTTP1::Connection.new($stdin)
	
	# input.write($stdin.read)
	# input.close

	begin
		host, method, path, version, headers, body = server.read_request
		
		body = server.read_request_body(method, headers)
	rescue Protocol::HTTP1::InvalidRequest
		# Ignore.
	end
end

if ENV["_"] =~ /afl/
	require 'kisaten'
	Kisaten.crash_at [], [], Signal.list['USR1']
	
	while Kisaten.loop 10000
		test
	end
else
	test
end