Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
Valeyard
Mar 30, 2012


Grimey Drawer
https://github.com/justinmeza/httpd.lol

epic, epic ftw

code:
OBTW
    httpd.lol -- a minimal HTTP server written in LOLCODE
    example:
        ./lci httpd.lol
        point your favorite HTTP-getter to [url]http://127.0.0.1:13337/lol.html[/url]
        ...
        profit?
    by Justin J. Meza, 2014
TLDR
HAI 1.4
    CAN HAS STDIO?
    CAN HAS SOCKS?
    CAN HAS STRING?

    HOW IZ I parse YR header
        I HAS A len ITZ I IZ STRING'Z LEN YR header MKAY
        I HAS A readin ITZ FAIL
        I HAS A file ITZ ""
        IM IN YR loop UPPIN YR index TIL BOTH SAEM index AN len
            I HAS A char ITZ I IZ STRING'Z AT YR header AN YR index MKAY
            BOTH OF BOTH SAEM char AN " " AN readin
            O RLY?
                YA RLY, FOUND YR file
            OIC
            readin, O RLY?, YA RLY, file R SMOOSH file AN char MKAY, OIC
            BOTH OF BOTH SAEM char AN "/" AN NOT readin
            O RLY?
                YA RLY, readin R WIN
            OIC
        IM OUTTA YR loop
        FOUND YR ""
    IF U SAY SO

    BTW bind to a local port
    I HAS A sock
    sock R I IZ SOCKS'Z BIND YR "127.0.0.1" AN YR 13337 MKAY

    IM IN YR loop
        BTW receive a connection
        I HAS A conn
        conn R I IZ SOCKS'Z LISTN YR sock MKAY

        BTW get a command
        I HAS A cmd
        cmd R I IZ SOCKS'Z GET YR sock AN YR conn AN YR 1024 MKAY
        VISIBLE "CMD IZ " AN cmd

        BTW parse the file name
        I HAS A name ITZ I IZ parse YR cmd MKAY
        VISIBLE "FIEL IZ " AN name

        I HAS A reply ITZ ""

        BTW get the file contents
        I HAS A file ITZ I IZ STDIO'Z OPEN YR name AN YR "r" MKAY
        I IZ STDIO'Z DIAF YR file MKAY, O RLY?
        YA RLY
            VISIBLE "FIEL NOT FOUND"
            reply R "HTTP/1.1 404 Not Found:3:):3:)"
        NO WAI
            VISIBLE "FIEL FOUND!"
            I HAS A data ITZ I IZ STDIO'Z LUK YR file AN YR 1024 MKAY
            I HAS A len ITZ I IZ STRING'Z LEN YR data MKAY
            I IZ STDIO'Z CLOSE YR file MKAY
            VISIBLE "LEN IZ " AN len
            VISIBLE "DATA IZ " AN data

            reply R SMOOSH "HTTP/1.1 200 OK:3:)"...
                    AN "Server: httpd.lol/0.1 (lci):3:)"...
                    AN "Context-Type: text/html:3:)"...
                    AN "Content-Length: :{len}:3:):3:)"...
                    AN ":{data}:3:)" MKAY
        OIC

	BTW serve it up
	VISIBLE "REPLY IZ " AN reply
	I IZ SOCKS'Z PUT YR sock AND YR conn AN YR reply MKAY

        BTW buh-bye
        I IZ SOCKS'Z CLOSE YR conn MKAY
    IM OUTTA YR loop
KTHXBYE

Adbot
ADBOT LOVES YOU

Butcher
Nov 29, 2004
TODO: Place Title Here
didn't laugh

pram
Jun 10, 2001
epic failhard

Valeyard
Mar 30, 2012


Grimey Drawer
if we port all the forums serverss over to lolcode, will it be more stable?

willt his work

Valeyard
Mar 30, 2012


Grimey Drawer

pram posted:

epic failhard

im gonna compile all your posts into a nice big tarball, zip it up real nice and then post it straight up your downstream pipe

A Wheezy Steampunk
Jul 16, 2006

High School Grads Eligible!
stop posting bad threads in yospos

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

Valeyard
Mar 30, 2012


Grimey Drawer
im stuck in a posting loop, it only breaks when i make a good one

CISADMIN PRIVILEGE
Aug 15, 2004

optimized multichannel
campaigns to drive
demand and increase
brand engagement
across web, mobile,
and social touchpoints,
bitch!
:yaycloud::smithcloud:

Valeyard posted:

im stuck in a posting loop, it only breaks when i make a good one

please get banned / probated again.

Adbot
ADBOT LOVES YOU

Bloody
Mar 3, 2013

CISADMIN PRIVILEGE posted:

please get banned / probated again.

  • Locked thread