Changeset 1365
- Timestamp:
- 02/25/08 00:20:28
- Files:
-
- HTTP/HTTPExtra.lua (modified) (4 diffs)
- HTTP/Token.lua (modified) (5 diffs)
- HTTP/WikiAbout.txt (modified) (2 diffs)
- HTTP/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
HTTP/HTTPExtra.lua
r1363 r1365 207 207 208 208 if aLength > 0 and not anEtag then 209 -- Requires Luiz Henrique de Figueiredo's lmd5library210 -- http:// www.tecgraf.puc-rio.br/~lhf/ftp/lua/5.1/lmd5.tar.gz211 local ok, md5 = pcall( require, 'md5' )212 213 if ok and md5then214 aResponse.header[ 'etag' ] = md5.digest( tostring( aResponse.content ) )209 -- Requires Klaus Ripke's slncrypto library 210 -- http://luaforge.net/projects/sln/ 211 local ok, crypto = pcall( require, 'crypto' ) 212 213 if ok and crypto then 214 aResponse.header[ 'etag' ] = crypto.sha1( tostring( aResponse.content ) ) 215 215 end 216 216 end … … 244 244 end 245 245 end 246 end247 248 function MD5Filter( aRequest, aResponse )249 local aLength = tonumber( aResponse.header[ 'content-length' ] ) or 0250 local aMD5 = aResponse.header[ 'content-md5' ]251 252 if aLength > 0 and not aMD5 then253 -- Requires Luiz Henrique de Figueiredo's lmd5 library254 -- http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/5.1/lmd5.tar.gz255 local ok, md5 = pcall( require, 'md5' )256 257 if ok and md5 then258 aResponse.header[ 'content-md5' ] = md5.digest( tostring( aResponse.content ) )259 end260 end261 246 end 262 247 … … 342 327 self.filter[ #self.filter + 1 ] = RangeFilter 343 328 self.filter[ #self.filter + 1 ] = ConditionalFilter 344 self.filter[ #self.filter + 1 ] = MD5Filter345 329 self.filter[ #self.filter + 1 ] = ContentFilter 346 330 self.filter[ #self.filter + 1 ] = ExpiresFilter … … 470 454 local function Hash( aPath, aSize, aModification ) 471 455 if aPath and aSize and aModification then 472 -- Requires Luiz Henrique de Figueiredo's lmd5library473 -- http:// www.tecgraf.puc-rio.br/~lhf/ftp/lua/5.1/lmd5.tar.gz474 local ok, md5 = pcall( require, 'md5' )475 476 if ok and md5then477 return md5.digest( aPath .. ':' .. aSize .. ':' .. aModification )456 -- Requires Klaus Ripke's slncrypto library 457 -- http://luaforge.net/projects/sln/ 458 local ok, crypto = pcall( require, 'crypto' ) 459 460 if ok and crypto then 461 return crypto.sha1( aPath .. ':' .. aSize .. ':' .. aModification ) 478 462 end 479 463 end HTTP/Token.lua
r1363 r1365 10 10 11 11 -- import dependencies 12 local md5 = require( 'md5' )12 local crypto = require( 'crypto' ) 13 13 local math = require( 'math' ) 14 14 local os = require( 'os' ) … … 43 43 local aDate = os.date( '*t', aTime ) 44 44 local aDateFormat = os.date( '!%A, %B %d %Y, %p %Z ', aTime ) 45 local aBase = md5.digest( ( '%s %s %s' ):format( aDateFormat, package.path, version ) )45 local aBase = crypto.sha1( ( '%s %s %s' ):format( aDateFormat, package.path, version ) ) 46 46 47 47 aDate = { year = aDate.year, month = aDate.month, day = aDate.day } … … 54 54 local aRandom = aContext.random 55 55 local aLength = aRandom( 3, 9 ) 56 local aStart = aRandom( 1, 32- aLength )56 local aStart = aRandom( 1, 40 - aLength ) 57 57 local anEnd = aStart + aLength - 1 58 58 … … 68 68 local aBase = aContext.base 69 69 local aRandom = aContext.random 70 local aSuffix = md5.digest( tostring( aRandom() ) )70 local aSuffix = crypto.sha1( tostring( aRandom() ) ) 71 71 local anID = ( '%s %s %s' ):format( aPrefix, aBase, aSuffix ) 72 72 73 anID = md5.digest( anID )73 anID = crypto.sha1( anID ) 74 74 anID = anID:sub( Range( aContext ) ) 75 anID = anID:gsub( '(%d)()', Convert ) 75 anID = anID:gsub( '(%d)()', Convert ):lower() 76 76 77 77 if not aContext[ anID ] then … … 95 95 96 96 function meta:__call( aPrefix, aTime ) 97 local aPrefix = md5.digest( tostring( aPrefix ) )97 local aPrefix = crypto.sha1( tostring( aPrefix ) ) 98 98 local aBase, aSeed = Base( aTime ) 99 99 local aRandom = Random( aSeed ) HTTP/WikiAbout.txt
r1352 r1365 34 34 <h4>Colophon</h4> 35 35 <ul> 36 <li><a href='http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/#lbase64' title='lbase64'>Base64</a> library by Luiz Henrique de Figueiredo</li>37 36 <li><a href='http://luaforge.net/projects/lzlib/' title='lzlib'>Compression</a> library by Tiago Dionizio</li> 37 <li><a href='http://luaforge.net/projects/sln/' title='slncrypto'>Cryptography</a> library by Klaus Ripke</li> 38 38 <li><a href='http://code.google.com/p/blueprintcss/' title='Blueprint'>CSS</a> framework by Olav Bjørkøy</li> 39 39 <li><a href='http://www.keplerproject.org/luafilesystem/' title='LuaFileSystem'>File</a> library by The Kepler Project</li> … … 42 42 <li><a href='http://www.frykholm.se/files/markdown.lua' title='makdown.lua'>Markdown</a> library by Niklas Frykholm</li> 43 43 <li><a href='http://daringfireball.net/projects/markdown/' title='Markdown'>Markdown</a> syntax by John Gruber</li> 44 <li><a href='http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/#lmd5' title='lmd5'>MD5</a> library by Luiz Henrique de Figueiredo</li>45 44 <li><a href='http://www.tecgraf.puc-rio.br/~diego/professional/luasocket/' title='LuaSocket'>Network</a> library by Diego Nehab</li> 46 <li><a href='http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/#lrandom' title='lrandom'>PRNG</a> library by Luiz Henrique de Figueiredo</li>47 45 <li><a href='http://interglacial.com/~sburke/tpj/as_html/tpj22.html' title='Unidecode'>Unidecode</a> by Sean M. Burke</li> 48 46 </ul> HTTP/readme.txt
r1351 r1365 26 26 DEPENDENCIES 27 27 28 lbase6429 http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/#lbase6430 31 lmd532 http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/#lmd533 34 lrandom35 http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/#lrandom36 37 28 lzlib 38 29 http://luaforge.net/projects/lzlib/ … … 47 38 http://www.tecgraf.puc-rio.br/~diego/professional/luasocket/ 48 39 40 slncrypto 41 http://luaforge.net/projects/sln/ 42 49 43 50 44 FEEDBACK