move since_last_modified function
This commit is contained in:
		
							parent
							
								
									eaafdbe577
								
							
						
					
					
						commit
						0bd0d3e11b
					
				
					 3 changed files with 13 additions and 12 deletions
				
			
		| 
						 | 
				
			
			@ -1,10 +0,0 @@
 | 
			
		|||
import {Context} from 'koa';
 | 
			
		||||
 | 
			
		||||
export function since_last_modified(ctx: Context, last_modified: Date): boolean{
 | 
			
		||||
    const con = ctx.get("If-Modified-Since");
 | 
			
		||||
    if(con === "") return false;
 | 
			
		||||
    const mdate = new Date(con);
 | 
			
		||||
    if(last_modified > mdate) return false;
 | 
			
		||||
    ctx.status = 304;
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -2,7 +2,7 @@
 | 
			
		|||
import {Context, DefaultContext, DefaultState, Next} from 'koa';
 | 
			
		||||
import StreamZip, { ZipEntry } from 'node-stream-zip';
 | 
			
		||||
import {orderBy} from 'natural-orderby';
 | 
			
		||||
import {since_last_modified} from '../content/util';
 | 
			
		||||
import {since_last_modified} from './util';
 | 
			
		||||
import {ContentContext} from './context';
 | 
			
		||||
import Router from 'koa-router';
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,6 @@
 | 
			
		|||
 | 
			
		||||
import {Context} from 'koa';
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
export function ParseQueryNumber(s: string|undefined): number| undefined{
 | 
			
		||||
    if(s === undefined) return undefined;
 | 
			
		||||
| 
						 | 
				
			
			@ -19,4 +21,13 @@ export function ParseQueryBoolean(s: string|undefined): [boolean,boolean|undefin
 | 
			
		|||
    else
 | 
			
		||||
        return [false,undefined]
 | 
			
		||||
    return [true,value]
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function since_last_modified(ctx: Context, last_modified: Date): boolean{
 | 
			
		||||
    const con = ctx.get("If-Modified-Since");
 | 
			
		||||
    if(con === "") return false;
 | 
			
		||||
    const mdate = new Date(con);
 | 
			
		||||
    if(last_modified > mdate) return false;
 | 
			
		||||
    ctx.status = 304;
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue