Skip to content

Instantly share code, notes, and snippets.

@thbwd
Created February 19, 2018 20:17
Show Gist options
  • Save thbwd/44d0649842df32cdad6267d6b12225a2 to your computer and use it in GitHub Desktop.
Save thbwd/44d0649842df32cdad6267d6b12225a2 to your computer and use it in GitHub Desktop.
HTTP Request
๐Ÿ“ฆ sockets ๐Ÿ”ด
๐Ÿ“ฆ files ๐Ÿ”ด
๐ŸŒฎ Represents the HTTP headers and status code ๐ŸŒฎ
๐Ÿ‡ ๐Ÿ™ ๐Ÿ‡
๐Ÿฐ statusCode ๐Ÿš‚
๐Ÿฐ headers ๐Ÿฏ๐Ÿš๐Ÿ”ก
๐Ÿˆ ๐Ÿ†• @statusCode ๐Ÿš‚ @headers ๐Ÿฏ๐Ÿš๐Ÿ”ก ๐Ÿ‡
๐Ÿฎ statusCode @statusCode
๐Ÿฎ headers @headers
๐Ÿ‰
๐Ÿ– ๐Ÿ’‚ โžก๏ธ ๐Ÿฏ๐Ÿš๐Ÿ”ก ๐Ÿ‡
๐ŸŽ headers
๐Ÿ‰
๐Ÿ– ๐Ÿ’ณ โžก๏ธ ๐Ÿš‚ ๐Ÿ‡
๐ŸŽ statusCode
๐Ÿ‰
๐Ÿ‰
๐ŸŒฎ Represents the destination of an HTTP Request ๐ŸŒฎ
๐Ÿ‡ ๐Ÿ“ ๐Ÿ‡
๐Ÿฐ host ๐Ÿ”ก
๐Ÿฐ path ๐Ÿ”ก
๐Ÿฐ port ๐Ÿš‚
๐Ÿฐ method ๐Ÿ”ก
๐Ÿฐ headers ๐Ÿฏ๐Ÿš๐Ÿ”ก
๐Ÿฐ body ๐Ÿฌ๐Ÿ“‡
๐Ÿฌ๐Ÿˆ ๐Ÿ†• url ๐Ÿ”ก @method ๐Ÿ”ก ๐Ÿ‡
๐ŸŠ โŽ๐ŸŽผ url ๐Ÿ”คhttp://๐Ÿ”ค ๐Ÿ‡
๐ŸŽโšก๏ธ
๐Ÿ‰
๐Ÿฎ host ๐Ÿ”ค๐Ÿ”ค
๐Ÿฎ path ๐Ÿ”ค๐Ÿ”ค
๐Ÿฎ port 80
๐Ÿฆ protocolless ๐Ÿ”ช url 7 ๐Ÿ” url
๐ŸŠ๐Ÿฆ :index ๐Ÿ” protocolless ๐Ÿ”ค:๐Ÿ”ค ๐Ÿ‡
๐Ÿฆ first/Index ๐Ÿบ๐Ÿ” protocolless ๐Ÿ”ค/๐Ÿ”ค
๐Ÿฎ port ๐Ÿบ๐Ÿš‚ ๐Ÿ”ช protocolless :index โž– first/Index :index 10
๐Ÿฎ host ๐Ÿ”ช protocolless 0 :index
๐Ÿฎ path ๐Ÿ”ช protocolless first/Index ๐Ÿ” protocolless
๐Ÿ‰
๐Ÿ“ ๐Ÿ‡
๐Ÿฆ first/Index ๐Ÿบ๐Ÿ” protocolless ๐Ÿ”ค/๐Ÿ”ค
๐Ÿฎ host ๐Ÿ”ช protocolless 0 first/Index
๐Ÿฎ path ๐Ÿ”ช protocolless first/Index ๐Ÿ” protocolless
๐Ÿ‰
๐Ÿฎ method @method
๐Ÿฎ headers ๐Ÿฏ
๐Ÿ”คHost๐Ÿ”ค host
๐Ÿ”คUser-Agent๐Ÿ”ค ๐Ÿ”คPavel Chekov๐Ÿ”ค
๐Ÿ†
๐Ÿ‰
๐Ÿ– ๐Ÿ’น string ๐Ÿ”ก โžก๏ธ ๐Ÿ”ก ๐Ÿ‡
๐Ÿฎ outString ๐Ÿ”ค๐Ÿ”ค
๐Ÿ”‚ symbol string ๐Ÿ‡
๐Ÿฆ code ๐Ÿš‚symbol
๐ŸŠ๐ŸŽ‰๐ŸŽŠโžก๏ธ code 0x31 โฌ…๏ธ code 0x39 ๐ŸŽ‰๐ŸŽŠโžก๏ธ code 0x41 โฌ…๏ธ code 0x5A ๐ŸŽ‰๐ŸŽŠโžก๏ธ code 0x61 โฌ…๏ธ code 0x7A
๐ŸŽ‰๐Ÿ˜› symbol ๐Ÿ”Ÿ- ๐ŸŽ‰๐Ÿ˜› symbol ๐Ÿ”Ÿ_ ๐ŸŽ‰๐Ÿ˜› symbol ๐Ÿ”Ÿ. ๐Ÿ˜› symbol ๐Ÿ”Ÿ~ย ๐Ÿ‡
๐Ÿฎ outString ๐Ÿ“ outString symbol
๐Ÿ‰
๐Ÿ“ ๐Ÿ‡
๐Ÿ”‚ byte ๐Ÿ“‡๐Ÿ”กsymbol ๐Ÿ‡
๐Ÿฎ outString ๐Ÿช outString ๐Ÿ”ค%๐Ÿ”ค ๐Ÿ”ก byte 16 ๐Ÿช
๐Ÿ‰
๐Ÿ‰
๐Ÿ‰
๐ŸŽ outString
๐Ÿ‰
๐ŸŒฎ
Sets the body to the data of the dictionary as `application/x-www-form-urlencoded` and sets
the according headers.
๐ŸŒฎ
๐Ÿ– ๐Ÿ“ง dict ๐Ÿฏ๐Ÿš๐Ÿ”ก ๐Ÿ‡
๐Ÿฆ outStrings ๐Ÿ”ท๐Ÿจ๐Ÿš๐Ÿ”ก๐Ÿธ
๐Ÿท headers ๐Ÿ”คContent-Type๐Ÿ”ค ๐Ÿ”คapplication/x-www-form-urlencoded๐Ÿ”ค
๐Ÿ”‚ key ๐Ÿ™ dict ๐Ÿ‡
๐Ÿป outStrings ๐Ÿช ๐Ÿ’น๐Ÿ• key ๐Ÿ”ค=๐Ÿ”ค ๐Ÿ’น๐Ÿ• ๐Ÿบ๐Ÿฝ dict key ๐Ÿช
๐Ÿ‰
๐Ÿ“ฉ๐Ÿ• ๐Ÿ“‡๐Ÿ”ท๐Ÿ”ก๐Ÿจ outStrings ๐Ÿ”ค&๐Ÿ”ค
๐Ÿ‰
๐ŸŒฎ Sets the body to `data` and sets the `Content-Length` header. ๐ŸŒฎ
๐Ÿ– ๐Ÿ“ฉ data ๐Ÿ“‡ ๐Ÿ‡
๐Ÿฎ body data
๐Ÿท headers ๐Ÿ”คContent-Length๐Ÿ”ค ๐Ÿ”ก๐Ÿ”data 10
๐Ÿ‰
๐ŸŒฎ Returns the path to the requested resource. ๐ŸŒฎ
๐Ÿ– ๐Ÿ—บ โžก๏ธ ๐Ÿ”ก ๐Ÿ‡
๐ŸŽ path
๐Ÿ‰
๐ŸŒฎ Returns the server address. ๐ŸŒฎ
๐Ÿ– ๐Ÿ› โžก๏ธ ๐Ÿ”ก ๐Ÿ‡
๐ŸŽ host
๐Ÿ‰
๐ŸŒฎ Returns the server port. ๐ŸŒฎ
๐Ÿ– ๐Ÿšช โžก๏ธ ๐Ÿš‚ ๐Ÿ‡
๐ŸŽ port
๐Ÿ‰
๐ŸŒฎ Returns the HTTP method. ๐ŸŒฎ
๐Ÿ– โ› โžก๏ธ ๐Ÿ”ก ๐Ÿ‡
๐ŸŽ method
๐Ÿ‰
๐ŸŒฎ Returns the headers in HTTP format. ๐ŸŒฎ
๐Ÿ– ๐Ÿ’‚ โžก๏ธ ๐Ÿ”ก ๐Ÿ‡
๐Ÿฎ outString ๐Ÿ”ค๐Ÿ”ค
๐Ÿ”‚ key ๐Ÿ™ headers ๐Ÿ‡
๐Ÿฎ outString ๐Ÿช outString key ๐Ÿ”ค: ๐Ÿ”ค ๐Ÿบ๐Ÿฝ headers key ๐Ÿ”คโŒrโŒn๐Ÿ”ค๐Ÿช
๐Ÿ‰
๐ŸŽ outString
๐Ÿ‰
๐ŸŒฎ Returns the body data to be sent to the server. ๐ŸŒฎ
๐Ÿ– ๐Ÿ“จ โžก๏ธ ๐Ÿฌ๐Ÿ“‡ ๐Ÿ‡
๐ŸŽ body
๐Ÿ‰
๐Ÿ‰
๐ŸŒฎ Represents a connection to an HTTP server. ๐ŸŒฎ
๐Ÿ‡ ๐Ÿ• ๐Ÿ‡
๐Ÿฐ socket ๐Ÿ“ž
๐Ÿฐ headerOverflowData ๐Ÿฌ๐Ÿ“‡
๐Ÿฐ request ๐Ÿ“
๐Ÿˆ ๐Ÿ†• @request ๐Ÿ“ ๐Ÿ‡
๐Ÿฎ request @request
๐Ÿฎ socket ๐Ÿบ ๐Ÿ”ท๐Ÿ“ž๐Ÿ†• ๐Ÿ›request ๐Ÿšชrequest
๐Ÿ‰
๐Ÿ– ๐Ÿ™ˆ callback ๐Ÿ‡๐Ÿ“‡๐Ÿ‰ โžก๏ธ ๐Ÿ™ ๐Ÿ‡
๐Ÿ’ฌ socket ๐Ÿ“‡ ๐Ÿชโ›request ๐Ÿ”ค ๐Ÿ”ค ๐Ÿ—บrequest ๐Ÿ”ค HTTP/1.1โŒrโŒn๐Ÿ”ค ๐Ÿ’‚request ๐Ÿ”คโŒrโŒn๐Ÿ”ค๐Ÿช
๐ŸŠ๐Ÿฆ data ๐Ÿ“จ request ๐Ÿ‡
๐Ÿ’ฌ socket data
๐Ÿ‰
๐Ÿฆ response ๐Ÿ˜Š๐Ÿ• ๐Ÿ˜ฎ๐Ÿ•
๐Ÿฆ headers ๐Ÿ’‚response
๐ŸŠ ๐Ÿ˜› โž—๐Ÿ’ณresponse 100 4 ๐Ÿ‡
๐Ÿ˜€ ๐Ÿ”ค4xx error๐Ÿ”ค
๐Ÿ‰
๐Ÿ‹ ๐Ÿ˜› โž—๐Ÿ’ณresponse 100 3 ๐Ÿ‡
๐ŸŠ ๐Ÿ˜› ๐Ÿ’ณresponse 301 ๐Ÿ‡
๐ŸŠ๐Ÿฆ location ๐Ÿฝ headers ๐Ÿ”คlocation๐Ÿ”ค ๐Ÿ‡
๐ŸŠ๐Ÿฆ nrequest ๐Ÿ”ท๐Ÿ“๐Ÿ†• location โ›request ๐Ÿ‡
๐Ÿฎ request nrequest
๐Ÿ™ˆ๐Ÿ• callback
๐Ÿ‰
๐Ÿ“ ๐Ÿ‡
๐Ÿ˜€ ๐Ÿช ๐Ÿ”คCannot follow ๐Ÿ”ค location ๐Ÿช
๐Ÿ‰
๐Ÿ‰
๐Ÿ“ ๐Ÿ‡
๐Ÿ˜€ ๐Ÿ”คNo Location given for 301๐Ÿ”ค
๐Ÿ‰
๐Ÿ‰
๐Ÿ‰
๐Ÿ‹ โŽ ๐Ÿ˜› ๐Ÿ’ณresponse 204 ๐Ÿ‡
๐ŸŠ๐Ÿฆ contentLength ๐Ÿฝ headers ๐Ÿ”คcontent-length๐Ÿ”ค ๐Ÿ‡
๐Ÿ™ƒ๐Ÿ• ๐Ÿบ๐Ÿš‚ contentLength 10 callback
๐Ÿ‰
๐Ÿ“ ๐Ÿ‡
๐Ÿ˜Œ๐Ÿ• callback
๐Ÿ‰
๐Ÿ‰
๐ŸŽ response
๐Ÿ‰
๐ŸŒฎ Parses the status-line and message-headers into a ๐Ÿ™ instance ๐ŸŒฎ
๐Ÿ” ๐Ÿ– ๐Ÿ˜Š message ๐Ÿ”ก โžก๏ธ ๐Ÿ™ ๐Ÿ‡
๐Ÿฆ headers ๐Ÿ”ซ message ๐Ÿ”คโŒrโŒn๐Ÿ”ค
๐Ÿฆ statusLineParts ๐Ÿ’ฃ ๐Ÿบ๐Ÿฝ headers 0 ๐Ÿ”Ÿ ๐Ÿจ headers 0
๐Ÿฆ headerDict ๐Ÿ”ท๐Ÿฏ๐Ÿš๐Ÿ”ก๐Ÿธ
๐Ÿ”‚ header headers ๐Ÿ‡
๐Ÿฆ :index ๐Ÿบ๐Ÿ” header ๐Ÿ”ค:๐Ÿ”ค
๐Ÿท headerDict ๐Ÿ“ช๐Ÿ”ช header 0 :index ๐Ÿ”ง๐Ÿ”ช header โž• :index 1 ๐Ÿ” header
๐Ÿ‰
๐ŸŽ ๐Ÿ”ท๐Ÿ™๐Ÿ†• ๐Ÿบ๐Ÿš‚ ๐Ÿบ๐Ÿฝ statusLineParts 1 10 headerDict
๐Ÿ‰
๐ŸŒฎ Receive start-line and headers as string ๐ŸŒฎ
๐Ÿ” ๐Ÿ– ๐Ÿ˜ฎ โžก๏ธ ๐Ÿ”ก ๐Ÿ‡
๐Ÿฆ endOfHeaders ๐Ÿ“‡๐Ÿ”คโŒrโŒnโŒrโŒn๐Ÿ”ค
๐Ÿฎ data ๐Ÿบ ๐Ÿ‘‚ socket 140
๐Ÿ” ๐Ÿ‘ ๐Ÿ‡
๐Ÿฆ index ๐Ÿ” data endOfHeaders
๐ŸŠ๐Ÿฆ index index ๐Ÿ‡
๐ŸŠ โ—€๏ธ โž• 4 index ๐Ÿ” data ๐Ÿ‡
๐Ÿฎ headerOverflowData ๐Ÿ”ช data โž• 4 index ๐Ÿ” data
๐Ÿ‰
๐ŸŽ ๐Ÿบ๐Ÿ”ก ๐Ÿ”ช data 0 index
๐Ÿ‰
๐Ÿฎ data ๐Ÿ“ data ๐Ÿบ ๐Ÿ‘‚ socket 140
๐Ÿ‰
๐ŸŽ ๐Ÿ”ค๐Ÿ”ค
๐Ÿ‰
๐ŸŒฎ
Receives body with the given length and calls the callback for every
received data package.
๐ŸŒฎ
๐Ÿ” ๐Ÿ– ๐Ÿ™ƒ wanted ๐Ÿš‚ callback ๐Ÿ‡๐Ÿ“‡๐Ÿ‰ ๐Ÿ‡
๐Ÿฎ stillWanted wanted
๐ŸŠ๐Ÿฆ ov headerOverflowData ๐Ÿ‡
๐Ÿฎ stillWanted โž– stillWanted ๐Ÿ” ov
๐Ÿญ callback ov
๐Ÿ‰
๐Ÿ” โ–ถ๏ธ stillWanted 0 ๐Ÿ‡
๐Ÿฆ data ๐Ÿบ ๐Ÿ‘‚ socket stillWanted
๐Ÿฎ stillWanted โž– stillWanted ๐Ÿ” data
๐Ÿญ callback data
๐Ÿ‰
๐Ÿ‰
๐ŸŒฎ
Receives body of unknown length and calls the callback for every received
data package.
๐ŸŒฎ
๐Ÿ” ๐Ÿ– ๐Ÿ˜Œ callback ๐Ÿ‡๐Ÿ“‡๐Ÿ‰ ๐Ÿ‡
๐ŸŠ๐Ÿฆ ov headerOverflowData ๐Ÿ‡
๐Ÿญ callback ov
๐Ÿ‰
๐Ÿ”๐Ÿฆ data ๐Ÿ‘‚ socket 500 ๐Ÿ‡
๐Ÿญ callback data
๐Ÿ‰
๐Ÿ‰
๐Ÿ‰
๐Ÿ ๐Ÿ‡
๐Ÿฆ file ๐Ÿบ ๐Ÿ”ท๐Ÿ“„๐Ÿ“ ๐Ÿ”คmaster.zip๐Ÿ”ค
๐Ÿ‘ด ๐Ÿฆ request ๐Ÿบ๐Ÿ”ท๐Ÿ“๐Ÿ†•๐Ÿ”คhttp://github.com/emojicode/emojicode/archive/master.zip๐Ÿ”ค ๐Ÿ”คGET๐Ÿ”ค
๐Ÿฆ request ๐Ÿบ๐Ÿ”ท๐Ÿ“๐Ÿ†•๐Ÿ”คhttp://127.0.0.1/~theo/post.php๐Ÿ”ค ๐Ÿ”คPOST๐Ÿ”ค
๐Ÿ“ง request ๐Ÿฏ ๐Ÿ”คname๐Ÿ”ค ๐Ÿ”คBรถle Mรผller๐Ÿ”ค ๐Ÿ”คpizza@๐Ÿ”ค ๐Ÿ”คDiavolo//๐Ÿ”ค ๐Ÿ”ค!๐Ÿ”ค ๐Ÿ”ค3322๐Ÿ”ค ๐Ÿ†
๐Ÿ™ˆ๐Ÿ”ท๐Ÿ•๐Ÿ†• request ๐Ÿ‡ d ๐Ÿ“‡
๐ŸŠ๐Ÿฆ string ๐Ÿ”กd ๐Ÿ‡
๐Ÿ˜€ string
๐Ÿ‰
๐Ÿ“ ๐Ÿ‡
๐Ÿ˜€ ๐Ÿ”ค!!!Unpritnable!!!๐Ÿ”ค
๐Ÿ‰
๐Ÿ‘ด โœ๏ธ file d
๐Ÿ‰
๐Ÿ‰
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment