An HTTP server for testing HTTP clients. Written in C#.
HeyHttp is a .NET C# console application that you can use to test your HTTP clients. It consists of:
hey.kiewic.com is a public server running multiple instances of HeyHttp, each with different configurations, for example:
http://hey.kiewic.com/
is a plain HTTP endpoint.https://hey.kiewic.com/
is an HTTPS endpoint.https://hey.kiewic.com:8080/
is an HTTPS endpoint that requires a client certificate.https://hey.kiewic.com:8081/
is an HTTPS endpoint with an expired certificate (NET::ERR_CERT_DATE_INVALID
).https://hey.foo.kiewic.com/
is an HTTPS endpoint with a certificate for a different domain name (ERR_CERT_COMMON_NAME_INVALID
).The source code is available on https://github.com/kiewic/heyhttp
CAUTION!
All the servers and clients included in this project are partially implemented.
Some features you can try are:
http://hey.kiewic.com/?delay=5000
to introduce a 5 seconds delay before starting to send a response.http://hey.kiewic.com/?slow=1000
to receive a response slowly, e.g., this configuration sends a package every 1000 milliseconds.http://hey.kiewic.com/?length=10240
to receive a response of 10240 bytes.http://hey.kiewic.com/?bufferLength=1024
to receive a response in chunks of 1024 bytes.http://hey.kiewic.com/?idleLength=2048
to indefinitely block the response thread until the client is disconnected when bufferLength * N >= idleLength
.http://hey.kiewic.com/?pause=1
to pause the writing of a response until the ENTER key is pressed.You can mix options, for example:
http://hey.kiewic.com/?slow=1000&bufferLength=1000&length=1000000
More options you can also mix:
http://hey.kiewic.com/?cache=1
to include headers in the response so content can be cached.http://hey.kiewic.com/?nocache=1
to include headers in the response that will prevent the content from being cached.http://hey.kiewic.com/?chunked=1
to receive a response with chunked transfer coding, i.e., using Transfer-Encoding: chunked
http://hey.kiewic.com/?gzip=1
to receive a response with GZIP coding, i.e., Transfer-Encoding: gzip
.http://hey.kiewic.com/?setcookie=1
to receive a response with multiple Set-Cookie
headers.http://hey.kiewic.com/?etag=1234
to receive a response with an ETag: 1234
header and an Accept-Ranges
header.http://hey.kiewic.com/?lastModified=1
to receive a response with a Last-Modified
header and an Accept-Ranges
header.http://hey.kiewic.com/?filename=something.ext
to receive a response with a Content-Disposition: attachment; filename=something.ext
header, so a client knows the response can be stored in the file system using the suggested name.http://hey.kiewic.com/?status=400
to receive a response with a 400 Not Found
status.http://hey.kiewic.com/?redirect=http%3A%2F%2Fexample.com
to receive a 301 Moved Permanently
response and a Location: http://example.com
header.http://hey.kiewic.com/?retry=1
to receive a 503 Service Unavailable
response with a Retry-After: 5
header.http://hey.kiewic.com/?basic=1
to receive a 401 Unauthorized
response with a WWW-Authenticate Basic
header.http://hey.kiewic.com/?digest=1
to receive a 401 Unauthorized
response with a WWW-Authenticate Digest
header.http://hey.kiewic.com/?negotiate=1
to receive a 401 Unauthorized
response with a WWW-Authenticate Negotiate
header.http://hey.kiewic.com/?ntlm=1
to receive a 401 Unauthorized
response with a WWW-Authenticate NTLM
header.http://hey.kiewic.com/?user=foo
to set the expected user name. If the request user name does not match foo, the response status is 401 Unauthorized
.http://hey.kiewic.com/?password=bar
to set the expected password. If the request password does not match bar, the response status is 401 Unauthorized
.It is common to use user and password options at the same time, for example:
http://hey.kiewic.com/?basic=1&user=foo&password=bar
Some more possible options:
http://hey.kiewic.com/?name=Foo&value=Bar
to receive a response with a Foo: Bar
header.http://hey.kiewic.com/?custom=1
to add three random custom headers.http://hey.kiewic.com/?trace=1
to receive the request headers back, as the content of the response.https://hey.kiewic.com/me.json
to recieve a JSON example response.To start the HTTP server, run HeyHttp.exe in the command prompt as:
HeyHttp.exe http server
To start the HTTPS server run the command:
HeyHttp.exe https server
To ask for a client certificate when a response is received run the command:
HeyHttp.exe https server -ClientCertificate
To select a server certificate run the command (for example):
HeyHttp.exe https server -Thumbprint "07261b17e0d71247b185234335c6126bc2796b6b"
More features:
CTRL + C
to kill all the current connections.CTRL + BREAK
to kill the process.Keep-Alive
connections.Range
and Content-Range
request headers.http://hey.kiewic.com/bar/foo.txt
returns the file at .\bin\Debug\wwwroot\bar\foo.txt
.Well, there are two easy ways to get started.
Download the binary and run it like this:
HeyHttp.exe http server
Or, if you want to use it as a client, like this:
HeyHttp.exe http client http://bing.com
Or, if you want to use it as a TCP server, like this:
HeyHttp.exe tcp server
Or, if you want to read other command line options, like this:
HeyHttp.exe /?
git clone https://github.com/kiewic/heyhttp
The HeyHttp mission is to provide servers and clients for testing, capable of reproduce scenarios that hardly occur in normal conditions using conventional servers and clients.
Everything is written with raw sockets, so it is possible to modify the protocols at any step.
Have you ever wonder why a website is or it is not caching? Is a website being redirected? Is a website setting cookies? This HTTP client is the easiest way to find out the answers.
To start the HTTP client type:
HeyHttp.exe http client http://my.msn.com
Add an extra header:
http client http://hey.kiewic.com/?ntlm=1 -H "Authorization: NTLM TlRMTVNTUAABAAAAA7IAAAoACgApAAAACQAJACAAAABMSUdIVENJVFlVUlNBLU1JTk9S"
Use a different HTTP method:
http client http://hey.kiewic.com/?ntlm=1 -X HEAD
To start the UDP receiver type:
HeyHttp.exe udp receiver [port]
To start the UDP sender type:
HeyHttp.exe udp sender [hostname] [port] [message]
On receiver mode, it listens for UDP packets in the given port.
On sender mode, it sends a package with the given message to the given hostname and port.
To start the SSL server type:
HeyHttp.exe ssl server
To configure the server certificate, please read the instructions in the Certificates.md file.
To start the HTTP proxy server type:
HeyHttp.exe proxy server
To skip proxy authentication type:
HeyHttp.exe proxy server -NoAuthentication
To configure a proxy:
Features: