TritonHTTP - A simple web server that implements a subset of the HTTP/1.1 protocol specification

Related tags

Network TritonHTTP
Overview

TritonHTTP

Spec Summary

Here we provide a concise summary of the TritonHTTP spec. You should read the spec doc for more details and clarifications.

HTTP Messages

TritonHTTP follows the general HTTP message format. And it has some further specifications:

  • HTTP version supported: HTTP/1.1
  • Request method supported: GET
  • Response status supported:
    • 200 OK
    • 400 Bad Request
    • 404 Not Found
  • Request headers:
    • Host (required)
    • Connection (optional, Connection: close has special meaning influencing server logic)
    • Other headers are allowed, but won't have any effect on the server logic
  • Response headers:
    • Date (required)
    • Last-Modified (required for a 200 response)
    • Content-Type (required for a 200 response)
    • Content-Length (required for a 200 response)
    • Connection: close (required in response for a Connection: close request, or for a 400 response)
    • Response headers should be written in sorted order for the ease of testing

Server Logic

When to send a 200 response?

  • When a valid request is received, and the requested file can be found.

When to send a 404 response?

  • When a valid request is received, and the requested file cannot be found or is not under the doc root.

When to send a 400 response?

  • When an invalid request is received.
  • When timeout occurs and a partial request is received.

When to close the connection?

  • When timeout occurs and no partial request is received.
  • When EOF occurs.
  • After sending a 400 response.
  • After handling a valid request with a Connection: close header.

When to update the timeout?

  • When trying to read a new request.

What is the timeout value?

  • 5 seconds.

Implementation

Please limit your implimentation to the following files, because we'll only copy over these files for grading:

  • pkg/tritonhttp/
    • request.go
    • response.go
    • server.go

There are some utility functions defined in pkg/tritonhttp/util.go that you might find useful.

You can (and are encouraged to) extend the tests (both unit and e2e tests) for your local testing. We'll use the same testing framework for grading, just with different test cases.

In terms of effort level, note that our solution involved writing 293 lines of new code (127 in server.go, 102 in request.go, and 64 in response.go).

Usage

Install the httpd command to a local bin directory:

make install
ls bin

Check the command help message:

bin/httpd -h

An alternative way to run the command:

go run cmd/httpd/main.go -h

Testing

Sanity Checking

We provide 2 simple examples for your sanity checking.

First you could run an example with the default server:

make run-default

This example uses the Golang standard library HTTP server to serve the website, and it doesn't rely on your implementation of TritonHTTP at all. So you shall be able to run it with the starter code right away. Open the link from output in a browser, and you shall see a test website.

Once you have a working implementation of TritonHTTP, you could run another example:

make run-tritonhttp

Again, you could use a browser to check the test website served.

Unit Testing

Unit tests don't involve any networking. They check the logic of the main parts of your implementation.

To run all the unit tests:

make unit-test

End-to-End Testing

End-to-end tests involve runing a server locally and testing by communicating with this server.

To run all the end-to-end tests:

make e2e-test

Manual Testing

For manutal testing, we recommend using nc.

In one terminal, start the TritonHTTP server:

go run cmd/httpd/main.go -port 8080 -doc_root test/testdata/htdocs

In another terminal, use nc to send request to it:

cat test/testdata/requests/single/OKBasic.txt | nc localhost 8080

You'll see the response printed out. And you could look at your server's logging to debug.

Submission

Either submit through GitHub, or:

make submission

And upload the generated submission.zip file to Gradescope.

Owner
Boyu Chen
code taylor / cs greenhand
Boyu Chen
A simple tool to convert socket5 proxy protocol to http proxy protocol

Socket5 to HTTP 这是一个超简单的 Socket5 代理转换成 HTTP 代理的小工具。 如何安装? Golang 用户 # Required Go 1.17+ go install github.com/mritd/[email protected] Docker 用户 docker pull m

mritd 6 Jun 25, 2022
Package arp implements the ARP protocol, as described in RFC 826. MIT Licensed.

arp Package arp implements the ARP protocol, as described in RFC 826. MIT Licensed. Portions of this code are taken from the Go standard library. The

Matt Layher 287 Jun 22, 2022
Gmqtt is a flexible, high-performance MQTT broker library that fully implements the MQTT protocol V3.1.1 and V5 in golang

中文文档 Gmqtt News: MQTT V5 is now supported. But due to those new features in v5, there area lots of breaking changes. If you have any migration problem

null 671 Jun 22, 2022
A STOMP Client package for go developers, supporting all STOMP specification levels.

stompngo - A STOMP 1.0, 1.1 and 1.2 Client Package Features Full support of STOMP protocols: Protocol Level 1.0 Protocol Level 1.1 Protocol Level 1.2

Guy M. Allard 138 Mar 7, 2022
rpc/v2 support for JSON-RPC 2.0 Specification.

rpc rpc/v2 support for JSON-RPC 2.0 Specification. gorilla/rpc is a foundation for RPC over HTTP services, providing access to the exported methods of

High Performance, Kubernetes Native Object Storage 3 Jul 4, 2021
Http-server - A HTTP server and can be accessed via TLS and non-TLS mode

Application server.go runs a HTTP/HTTPS server on the port 9090. It gives you 4

Vedant Pareek 0 Feb 3, 2022
A Language Server Protocol (LSP) server for Jsonnet

Jsonnet Language Server Warning: This project is in active development and is likely very buggy. A Language Server Protocol (LSP) server for Jsonnet.

Jack Baldry 17 Apr 29, 2022
Package dhcp6 implements a DHCPv6 server, as described in RFC 3315. MIT Licensed.

dhcp6 Package dhcp6 implements a DHCPv6 server, as described in IETF RFC 3315. MIT Licensed. At this time, the API is not stable, and may change over

Matt Layher 74 May 8, 2022
Syslogpars - Simple syslog server, working to UDP-protocol

syslogparse Simple syslog server, working to UDP-protocol. Server was tested wit

null 0 Jan 22, 2022
A simple FTP protocol with client and server implemented in TypeScript and Golang

websocket-ftp A simple FTP protocol with client and server implemented in TypeScript and Golang. Example (Client) const buffer: Uint8Array = (new Text

LQR471814 0 Apr 14, 2022
🔎Sniffing and parsing mysql,redis,http,mongodb etc protocol. 抓包截取项目中的数据库请求并解析成相应的语句。

go-sniffer Capture mysql,redis,http,mongodb etc protocol... 抓包截取项目中的数据库请求并解析成相应的语句,如mysql协议会解析为sql语句,便于调试。 不要修改代码,直接嗅探项目中的数据请求。 中文使用说明 Support List: m

Four 1.6k Jun 29, 2022
File Collector is an application that uses HTTP protocol to collect homework and files.

File Collector File Collector is an application that uses HTTP protocol to collect homework and files. Usage When filecollector is run, it will automa

毛亚琛 1 Jun 16, 2022
A plugin of protoc that for using a service of Protocol Buffers as http.Handler definition

protoc-gen-gohttp protoc-gen-gohttp is a plugin of protoc that for using a service of Protocol Buffers as http.Handler definition. The generated inter

John_Suu 1 Dec 9, 2021
A standalone Web Server developed with the standard http library, suport reverse proxy & flexible configuration

paddy 简介 paddy是一款单进程的独立运行的web server,基于golang的标准库net/http实现。 paddy提供以下功能: 直接配置http响应 目录文件服务器 proxy_pass代理 http反向代理 支持请求和响应插件 部署 编译 $ go build ./main/p

fangyousong 5 May 2, 2022
A http-relay server/client written in golang to forward requests to a service behind a nat router from web

http-relay This repo is WIP http-relay is a server/client application written in go(lang) to forward http(s) requests to an application behind a nat r

john dev 1 Dec 16, 2021
Go-http-sleep: Delayed response http server, useful for testing various timeout issue for application running behind proxy

delayed response http server, useful for testing various timeout issue for application running behind proxy

guessi 0 Jan 22, 2022
A TCP Server Framework with graceful shutdown, custom protocol.

xtcp A TCP Server Framework with graceful shutdown,custom protocol. Usage Define your protocol format: Before create server and client, you need defin

xfx 132 Jun 5, 2022
Scalable WebRTC Signaling Server with ayame-like protocol.

ayu ayu is WebRTC Signaling Server with ayame-like protocol. Scalable: ayu uses Redis to store room states, so it can be used on serverless platforms

castaneai 23 Jun 3, 2022