1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2025-08-09 01:25:00 +00:00

Uthernet II found! Fix HTTPD!

This commit is contained in:
David Schmenk
2018-02-23 17:11:55 -08:00
parent 6eb842e472
commit 03923a9825

View File

@@ -11,13 +11,13 @@
include "inc/cmdsys.plh" include "inc/cmdsys.plh"
include "inc/inet.plh" include "inc/inet.plh"
include "inc/fileio.plh" include "inc/fileio.plh"
include "inc/conio.plh"
word socketHTTP word socketHTTP
byte[65] prefix byte[65] prefix
word filebuff, iobuff word filebuff
byte fileInfo[12] = 0 // used for get_file_info() byte[15] fileInfo = 0 // used for get_file_info()
byte hello = "Apple II Web Server - 12 Nov 15\n" byte defhtml = "INDEX.HTML"
byte defhtml = "INDEX.HTML"
byte[200] okhdr // combined response header byte[200] okhdr // combined response header
// //
// HTTP response codes // HTTP response codes
@@ -78,7 +78,7 @@ def strcat2(dst, src1, src2)
return dst return dst
end end
def itos(dst, i) def itos(dst, i)
if i < 0; ^dst = '-'; i = -i; dst = dst + 1; fin if i < 0; ^dst = '-'; i = -i; dst++; fin
if i < 10 if i < 10
^dst = i + '0' ^dst = i + '0'
else else
@@ -141,7 +141,6 @@ def servHTTP(remip, remport, lclport, data, len, param)
// Get file info // Get file info
// //
//puts("getting file info "); // debug //puts("getting file info "); // debug
fileio:getfileinfo(@filename)
refnum = fileio:open(@filename) // try to open this file with ProDOS refnum = fileio:open(@filename) // try to open this file with ProDOS
if refnum // file was opened OK if refnum // file was opened OK
filelen = fileio:geteof(refnum) // get length of file for Content-Length filelen = fileio:geteof(refnum) // get length of file for Content-Length
@@ -152,7 +151,8 @@ def servHTTP(remip, remport, lclport, data, len, param)
// //
// Content type header // Content type header
// //
if fileInfo.4 == $03 OR fileInfo.4 == $04 fileio:getfileinfo(@filename, @fileInfo)
if fileInfo.1 == $03 OR fileInfo.1 == $04
// //
// this a text file // this a text file
// //
@@ -181,8 +181,8 @@ def servHTTP(remip, remport, lclport, data, len, param)
else // file couldn't be opened, so return 404 on this else // file couldn't be opened, so return 404 on this
puts("404 Not Found");putln // debug puts("404 Not Found");putln // debug
iNet:sendTCP(socketHTTP, @httpNOTFOUND + 1, httpNOTFOUND) iNet:sendTCP(socketHTTP, @httpNOTFOUND + 1, httpNOTFOUND)
fin // if refnum fin // refnum
break // return break
fin fin
next next
else else
@@ -196,7 +196,7 @@ end
if !iNet:initIP() if !iNet:initIP()
return -1 return -1
fin fin
puts(@hello) puts("PLASMA Web Server, Version 1.0\n")
fileio:getpfx(@prefix) fileio:getpfx(@prefix)
// //
// Alloc aligned file/io buffers // Alloc aligned file/io buffers
@@ -213,7 +213,6 @@ repeat
socketHTTP = iNet:listenTCP(80, @servHTTP, 0) socketHTTP = iNet:listenTCP(80, @servHTTP, 0)
fin fin
iNet:serviceIP() iNet:serviceIP()
until ^$C000 > 127 until conio:keypressed()
^$C010
done done