仕様書などを見ていけば、それなりにHTTPDサーバーが出来ます。
http://www.studyinghttp.net/
大昔に作ったHTTPDサーバーもどき。
適当に組んだものですので、バグはあるかと。
メソッドもGETしか使えませんが、お遊びみたいなものなので参考程度にどうぞ。
//http://localhost/でアクセスできます。
//例えば、ソースフォルダにtest.bmpがありますと
//http://localhost/test.bmpとブラウザに入れるとダウンロードされます。
#include "hspsock.as"
port=80
*s
sockmake 0,port
switch stat
case 1
dialog "TCP/IPがWindowsにインストールされていない":end
swbreak
case 2
dialog "ソケットの初期化に失敗した":end
swbreak
case 3
dialog "Socketのバインドに失敗した\n(ポートが開いていない)":end
swbreak
swend
title "接続待ち..."
repeat
title ">"+cnt
sockwait 0
if stat=0:break
wait 1
loop
title "受信中..."
sdim p,4096:buf2=""
sockget p,1024,0
buf2+=p
//解析する
if strmid(buf2,0,3)!="GET":goto *e //GETメソッドのみサポート
indexA=instr(buf2,3," ")
if indexA=-1:goto *e //変なリクエストなので400
indexB=instr(buf2,3+indexA+1," ")
if indexA=indexB:goto *e //変なリクエストなので400
request_fname=strmid(buf2,indexA+4+1,indexB-indexA)
exist request_fname
if strsize=-1:goto *n //HTTP 404
size=strsize
//OKみたいなので送信
header= "HTTP/1.1 200 OK\n"
header+="Accept-Ranges: bytes\n
header+="Content-Length: "+size+"\n"
header+="Connection: close\n"
//header+="Client-Response-Num: 1\n"
//header+="Content-Type: image/x-MS-bmp\n"
header+="\n"
h=strlen(header)
memexpand header,h+size
sdim buf,size
bload request_fname,buf,size,0
memcpy header,buf,size,h,0
sockputb header,0,h+size,0
sockclose
mes "HTTP_Request : /"+request_fname+" *size : "+size+"bytes":ci++
if ci>26:color 255,255,255:boxf:color:pos 0,0:ci=0
goto *s
*e
;dialog "400"
sockput "HTTP/1.1 400 Bad Request\nConnection: close\n\nHTTP 400",0
sockclose
goto *s
*n
;dialog "404"
sockput "HTTP/1.1 404 Not Found\nConnection: close\n\nHTTP 404",0
sockclose
goto *s