Changeset 1365

Show
Ignore:
Timestamp:
02/25/08 00:20:28
Author:
rsz
Message:

cleanup

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • HTTP/HTTPExtra.lua

    r1363 r1365  
    207207 
    208208        if aLength > 0 and not anEtag then 
    209             -- Requires Luiz Henrique de Figueiredo's lmd5 library 
    210             -- http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/5.1/lmd5.tar.gz 
    211             local ok, md5 = pcall( require, 'md5' ) 
    212          
    213             if ok and md5 then 
    214                 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 ) ) 
    215215            end 
    216216        end 
     
    244244        end 
    245245    end     
    246 end 
    247  
    248 function MD5Filter( aRequest, aResponse ) 
    249     local aLength = tonumber( aResponse.header[ 'content-length' ] ) or 0 
    250     local aMD5 = aResponse.header[ 'content-md5' ] 
    251      
    252     if aLength > 0 and not aMD5 then 
    253         -- Requires Luiz Henrique de Figueiredo's lmd5 library 
    254         -- http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/5.1/lmd5.tar.gz 
    255         local ok, md5 = pcall( require, 'md5' ) 
    256          
    257         if ok and md5 then 
    258             aResponse.header[ 'content-md5' ] = md5.digest( tostring( aResponse.content ) ) 
    259         end 
    260     end 
    261246end 
    262247 
     
    342327self.filter[ #self.filter + 1 ] = RangeFilter 
    343328self.filter[ #self.filter + 1 ] = ConditionalFilter 
    344 self.filter[ #self.filter + 1 ] = MD5Filter 
    345329self.filter[ #self.filter + 1 ] = ContentFilter 
    346330self.filter[ #self.filter + 1 ] = ExpiresFilter 
     
    470454local function Hash( aPath, aSize, aModification  ) 
    471455    if aPath and aSize and aModification then 
    472         -- Requires Luiz Henrique de Figueiredo's lmd5 library 
    473         -- http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/5.1/lmd5.tar.gz 
    474         local ok, md5 = pcall( require, 'md5' ) 
    475      
    476         if ok and md5 then 
    477             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 ) 
    478462        end 
    479463    end 
  • HTTP/Token.lua

    r1363 r1365  
    1010 
    1111-- import dependencies 
    12 local md5 = require( 'md5' ) 
     12local crypto = require( 'crypto' ) 
    1313local math = require( 'math' ) 
    1414local os = require( 'os' ) 
     
    4343    local aDate = os.date( '*t', aTime ) 
    4444    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 ) ) 
    4646     
    4747    aDate = { year = aDate.year, month = aDate.month, day = aDate.day } 
     
    5454    local aRandom = aContext.random 
    5555    local aLength = aRandom( 3, 9 ) 
    56     local aStart = aRandom( 1, 32 - aLength )  
     56    local aStart = aRandom( 1, 40 - aLength )  
    5757    local anEnd = aStart + aLength - 1 
    5858     
     
    6868    local aBase = aContext.base 
    6969    local aRandom = aContext.random 
    70     local aSuffix = md5.digest( tostring( aRandom() ) ) 
     70    local aSuffix = crypto.sha1( tostring( aRandom() ) ) 
    7171    local anID = ( '%s %s %s' ):format( aPrefix, aBase, aSuffix ) 
    7272     
    73     anID = md5.digest( anID ) 
     73    anID = crypto.sha1( anID ) 
    7474    anID = anID:sub( Range( aContext ) ) 
    75     anID = anID:gsub( '(%d)()', Convert ) 
     75    anID = anID:gsub( '(%d)()', Convert ):lower() 
    7676     
    7777    if not aContext[ anID ] then 
     
    9595 
    9696function meta:__call( aPrefix, aTime ) 
    97     local aPrefix = md5.digest( tostring( aPrefix ) ) 
     97    local aPrefix = crypto.sha1( tostring( aPrefix ) ) 
    9898    local aBase, aSeed = Base( aTime ) 
    9999    local aRandom = Random( aSeed ) 
  • HTTP/WikiAbout.txt

    r1352 r1365  
    3434                <h4>Colophon</h4> 
    3535                <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> 
    3736                    <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> 
    3838                    <li><a href='http://code.google.com/p/blueprintcss/' title='Blueprint'>CSS</a> framework by Olav Bjørkøy</li> 
    3939                    <li><a href='http://www.keplerproject.org/luafilesystem/' title='LuaFileSystem'>File</a> library by The Kepler Project</li> 
     
    4242                    <li><a href='http://www.frykholm.se/files/markdown.lua' title='makdown.lua'>Markdown</a> library by Niklas Frykholm</li> 
    4343                    <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> 
    4544                    <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> 
    4745                    <li><a href='http://interglacial.com/~sburke/tpj/as_html/tpj22.html' title='Unidecode'>Unidecode</a> by Sean M. Burke</li> 
    4846                </ul> 
  • HTTP/readme.txt

    r1351 r1365  
    2626DEPENDENCIES 
    2727 
    28     lbase64 
    29     http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/#lbase64 
    30  
    31     lmd5 
    32     http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/#lmd5 
    33  
    34     lrandom 
    35     http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/#lrandom 
    36  
    3728    lzlib 
    3829    http://luaforge.net/projects/lzlib/ 
     
    4738    http://www.tecgraf.puc-rio.br/~diego/professional/luasocket/ 
    4839 
     40    slncrypto 
     41    http://luaforge.net/projects/sln/ 
     42 
    4943 
    5044FEEDBACK