判断⽂文件的状态fs.stat的mime对⽐比 request.headers['if-modified-since'],如果⽂文件修改 时间变化则response.setHeader('Last-Modified','')

Expires/Cache-Control response.setHeader('Expires','')/ response.setHeader('Cache-Control','max-age=')

缓存(304)

也可以通过私钥签名进⾏行加密(原始值+ '.' + 签名密 ⽂文);服务器端获取原始值重新签名加密后进⾏行对⽐比

Etag 将⽂文件内容hash值和request.headers['if-nonemach']对⽐比,如果有变化 response.setHeader('ETag','') request.on('data',fn)获取body

request.headers.cookie中取; response.setHeader('Set-Cookie',value)设置

Cookie

HTTP请求

随机⽣生成session_id,写cookie ⽆无(登录)

判断request.headers 中是否有'transfer-encoding'或 者'content-length' request.on('end',fn)组合数据并处理

创建cookie['session_id']对应的服务端session

获取请求头的内容,判断是否包含body内容

数据安全校验(如XSS过滤,上传⽂文件的⻓长度对⽐比 request.headers['content-length'])

数据上传

基于Cookie

Components - 中间件

通过request.headers['Content-Type']判断

分析request中cookie中是否包含session_id的映射信 息

⽆无

有(判断服务端session是否有cookie对应的映射)

判断请求数据的类型进⾏行格式化

有效期内 Session

有(分析有效期)

处理渲染

失效(更新失效时间)

基于URL

路径⼿手⼯工配置或正则匹配

服务器端⽣生成session串和失效时间,并将session串放 置于URL的query参数中,根据这种对应关系进⾏行判 断,业务⽅方法cookie累似

路由 URL规则映射

server.listen(port, [hostname], [backlog], [callback])/server.listen(path, [callback])/ server.listen(handle, [callback]) ⽅方法

server.close([callback]) response.setHeader(name, value)/ response.getHeader(name)/ response.removeHeader(name)/ response.writeHead(statusCode, [reasonPhrase], [headers])/response.addTrailers(headers)

server.setTimeout(msecs, callback) 事件:close/finish

属性 - server.maxHeadersCount/server.timeout response.write(chunk, [encoding])/ response.end([data], [encoding])/ response.writeContinue()

Server - http.createServer([requestListener])

⽅方法

serverResponse

request:function (request, response) { } HTTPS

response.setTimeout(msecs, callback) connection:function (socket) { } 属性:response.statusCode/response.sendDate/ response.headersSent

checkContinue:function (request, response) { } 事件

connect:function (request, socket, head) { }

response:function (response) { } socket:function (socket) { }

upgrade:function (request, socket, head) { } HTTP

connect:function (response, socket, head) { }

upgrade:function (response, socket, head) { } url.parse(urlStr,[parseQueryString], [slashesDenoteHost])

querystring.escape() - 作为备⽤用,可以相当于 stringify⽅方法

url.resolve(from,to) - 合并路径

querystring.unescape() - 备⽤用同上

uid/gid

URL

Properties

fs.readSync(fd, buffer, offset, length, position, callback(err,bytesRead,buffer))

字符串

path = pathname + search

blocks

Properties ⽂文件属性/状态操作 - 基于⽂文件/基于⽂文件描述符

stats.isDirectory()

decoder.end() - 返回buffer字节数

stats.isBlockDevice() Path

path.join([path1], [path2], [...]) = path.normallize(path1 + path2 + ...) - 合并路径

stats.isSymbolicLink() (only valid with fs.lstat())

Methods

request.setSocketKeepAlive([enable], [initialDelay])

实现

fs.readFileSync(filename, [options], callback(err,data))

Methods 直接操作 - 基于⽂文件

fs.existsSync(path, callback) - ⽂文件是否存在

process.execPath/process.execArgv

fs.writeFileSync(filename, data, [options], callback) fs.appendFileSync(filename, data, [options], callback)

fs.utimesSync(path, atime, mtime, callback) fs.futimesSync(fd, atime, mtime, callback) - 修改⽂文 件的访问和创建时间

path = path.diranme(p) + / + path.basename(p, [ext])

watcher.close()

uncaughtException

链接⽂文件操作

Readable Stream - fs.createReadStream(path, [options]) ⽂文件流操作

fs.mkdirSync(path, [mode], callback) Writalbe Stream - fs.createWriteStream(path, [options])

Async异步Event Loop

⽅方法

process.kill(pid, [signal])/process.exit([code])/ process.abort()

进程/线程

fs.symlinkSync(srcpath, dstpath, [type], callback) 软链接类似于快捷⽅方式

process.umask([mask])/process.uptime()/ process.hrtime()

fs.readlinkSync(path, callback(err,resolvedPath)) 读取⽂文件的链接地址 - 只对软链接有效

process.getgid()/process.setgid(id)/ process.getuid()/process.setuid(id)/ process.getgroups()/process.setgroups(groups)/ process.initgroups(user, extra_group)

Server net.createServer([options], [connectionListener]) - callback参数socket

socket.connect(port, [host], [connectListener]) socket.connect(path, [connectListener])

属性:server.maxConnections / server.connections

unref() - 如果Async函数绑定了unref()⽅方法,若它是 event loop队列中最后⼀一个待执⾏行函数,则不执⾏行 ⽅方法

socket.setEncoding([encoding]) 事件:listening/connection/close/error ref() - 可以通过此⽅方法终⽌止unref()的功能

socket.write(data, [encoding], [callback])

Connection

socket.end([data], [encoding]) ⽅方法

fs.realpathSync(path, [cache], callback) - 返回 path的绝对路径

child_process.spawn(command, [args], [options])/ child_process.exec(command, [options], callback)/child_process.execFile(file, [args], [options], [callback])/ child_process.fork(modulePath, [args], [options]) ⽅方法

fs.rmdirSync(path, callback)

server.getConnections(callback)

process.nextTick(callback)/ process.memoryUsage()/process.cwd()

fs.readdirSync(path, callback)

⽂文件夹操作

⽅方法

server.unref() server.ref()

change

Event

fs.linkSync(srcpath, dstpath, callback) - 硬链接: srcpath和dstpath指向同⼀一个node节点

server.address()

signal

error

path.basename(p,[ext]) = name + path.extname(p)

server.close([callback])

事件

stats.isFIFO() stats.isSocket()

server.listen(port, [host], [backlog], [callback]) server.listen(path, [callback]) server.listen(handle, [callback])

idl观察者:process.nextTick() > check观察 者:setImmediate()

exit Process

fs.watch(filename/dir, [options], listener(event,filename)) - 替代之前⽂文档的 fs.watchFile,fs.unwatchFile - 监听⽂文件 - 返回 FSWatcher

Timer

process.version/process.versions/process.config/ process.pid/process.title/process.arch/ process.platform/process.maxTickDepth

fs.truncateSync(path, len, callback) - 拆取⽂文件

path.relative(from, to) - 获取路径to相对于路径from 的相对路径

IO

process.argv/process.env

属性

stats.isCharacterDevice()

path.resolve([from ...], to) - 相当于不断的掉系统的 cd命令切换⺫⽬目录

⽅方法 http.globalAgent

fs.writeSync(fd, buffer, offset, length, position, callback(err,bytesWritten,buffer))

fs.closeSync(fd, callback) ⽂文件系统

path.delimiter - 相当于路径中的 ';' 或者 ':'

request.setTimeout(timeout, [callback])/ request.setNoDelay([noDelay])

process.stdin/process.stdout/process.stderr

fs.statSync(path, callback(err,stats)) fs.fstatSync(fd, callback) fs.lstatSync(path, callback) - 查看⽂文件/链接⽂文件的信息 - 返回stats

stats.isFile()

Properties

Client - http.createClient([port], [host])/ http.request(options, [callback])/http.get(options, [callback])

fs.fsyncSync(fd, callback) - 同步磁盘缓存

decoder.write(buffer) path.sep - 相当于路径中的‘/’或者 '//'

httpRequest

fs.ftruncateSync(fd, len, callback) - 拆取⽂文件

⽂文件操作

atime/mtime/ctime

search = ? + query

StringDecoder - new StringDecoder(charset)

常规步骤(open -> operate基于⽂文件描述符-> close)

fs.chmodSync(path, mode, callback) fs.fchmodSync(fd, mode, callback) fs.lchmodSync(path, mode, callback) - 修改⽂文件/ 链接⽂文件权限

blsize/size

http.agent

agent.requests - 返回请求的队列

rdev href = protocol + // + auth + @ + hostname + : + port + path + # + hash

request.write(chunk, [encoding])/ request.end([data], [encoding])/request.abort()

fs.openSync(path, flags, [mode], callback(err,fd))

fs.chownSync(path, uid, gid, callback) fs.fchownSync(fd, uid, gid, callback) - 修改⽤用户/⽤用 户组信息

nlink

querystring.parse(str, [sep], [eq], [options])

agent.maxSockets - 默认最⼤大5个

agent.sockets - 返回当前socket array

mode

Query String

事件

ino

Methods

querystring.stringify(obj,[sep],[eq])

clientError:function (exception, socket) { }

continue:function () { }

dev url.format(urlObj)

TLS/SSL

fs.unlinkSync(path, callback) - 删除⽂文件

socket.destroy()/socket.parse()/socket.resume()

connect与createConnection的区别:connect返 回的是当前的单⼀一连接,⽽而createConnection返回的 是连接对象

child.send(message, [sendHandle])/ child.disconnect()

Child-Process

net.connect(options, [connectionListener]) net.createConnection(options, [connectionListener])

net.connect(port, [host], [connectListener]) net.createConnection(port, [host], [connectListener])

NET/TCP

Socket new net.Socket(),client connection或 server 连接参数 - "套接字",⽤用于描述IP地址和端⼝口, 是⼀一个通信链的句柄。

socket.setTimeout(timeout, [callback]) socket.setNoDelay([noDelay]) socket.setKeepAlive([enable], [initialDelay])

Client - 返回socket socket.address() socket.unref()/socket.ref()

readable.read([size])

net.connect(path, [connectListener]) net.createConnection(path, [connectListener])

属性:stdin/stdout/stderr/pid/connected

属性:bufferSize/remoteAdress/remotePort/ localPort/localAdress/byteRead/byteWritten

readable.setEncoding(encoding) Buffer.isBuffer(obj) ⽅方法 Class Method

net.isIP(input)

readable.resume()/readable.pause() - ⽤用于激活或 者阻⽌止监听data事件

事件:error/close/disconnect/message

net.isIPv4(input)

readable.pipe(destination, [options])/ readable.unpipe([destination]) - destination是 Writable Stream

Buffer.byteLength(string, [encoding]) stream.Readable Buffer.concat(list, [totalLength])

net.isIPv6(input)

readable.unshift(chunk)/readable.wrap(stream) wrap⽤用于把之前版本的stream封装成当前的接⼝口

buf[index] - 值为0-255的某⼀一值,如果设置时不为这 些值,则会对⻬齐相应的转换

事件:connect/data/end/timeout/drain/error/ close

Methods

os.platform()/os.arch()

事件listening/message/close/error

属性

Buffer

buf.length - 字节⻓长度

socket.bind(port, [address], [callback])

事件:readable/data/end/close/error 系统(OS)

os.totalmem()/os.freemem()/os.cpus() socket.send(buf, offset, length, port, address, [callback])

dgram.createSocket(type,[callback])

UDP/dgram

⺴⽹网络传输层

其他

实例化对象 new Buffer(size/array/str,[encoding]) size字节⻓长度

writable.write(chunk, [encoding], [callback])

socket.close()

⽅方法

⽅方法

buf.write(string, [offset], [length], [encoding]) 流底层的具体实现参考官⽅方API DOC

Stream流

stream.Writable

writable.end([chunk], [encoding], [callback])

socket.address() socket.setBroadcast(flag) socket.setMulticastLoopback(flag)

buf.copy(targetBuffer, [targetStart], [sourceStart], [sourceEnd]) 事件:drain/finish/pipe/unpipe/error

⽅方法

socket.setTTL(ttl) / socket.setMulticastTTL(ttl) buf.slice([start], [end]) tcp sockets

buf.toString([encoding], [start], [end]) / buf.toJSON() stream.Duplex - both the Readable and Writable

zlib streams

复杂的读写 如:buf.readInt8(offset, [noAssert]) buf.writeInt8(value, offset, [noAssert]) crypto streams Global: buffer.inspect() buffer.INSPECT_MAX_BYTES 默认50

stream.Transform - Duplex streams where the output is in some way computed from the input

zlib streams

crypto streams

socket.ref() / socket.unref()

⺴⽹网络

DNS/IP

UDP/dgram - GitHub

server 连接参数- "套接字",⽤用于描述IP地址和端⼝口,. 是⼀一个通信链的 .... nextTick() > check观察. 者:setImmediate ... process.umask([mask])/process.uptime()/.

271KB Sizes 7 Downloads 216 Views

Recommend Documents

GitHub
domain = meq.domain(10,20,0,10); cells = meq.cells(domain,num_freq=200, num_time=100); ...... This is now contaminator-free. – Observe the ghosts. Optional ...

GitHub
data can only be “corrected” for a single point on the sky. ... sufficient to predict it at the phase center (shifting ... errors (well this is actually good news, isn't it?)

Torsten - GitHub
Metrum Research Group has developed a prototype Pharmacokinetic/Pharmacodynamic (PKPD) model library for use in Stan 2.12. ... Torsten uses a development version of Stan, that follows the 2.12 release, in order to implement the matrix exponential fun

Untitled - GitHub
The next section reviews some approaches adopted for this problem, in astronomy and in computer vision gener- ... cussed below), we would question the sensitivity of a. Delaunay triangulation alone for capturing the .... computation to be improved fr

ECf000172411 - GitHub
Robert. Spec Sr Trading Supt. ENA West Power Fundamental Analysis. Timothy A Heizenrader. 1400 Smith St, Houston, Tx. Yes. Yes. Arnold. John. VP Trading.

Untitled - GitHub
Iwip a man in the middle implementation. TOR. Andrea Marcelli prof. Fulvio Risso. 1859. Page 3. from packets. PEX. CethernetDipo topo data. Private. Execution. Environment to the awareness of a connection. FROG develpment. Cethernet DipD tcpD data. P

BOOM - GitHub
Dec 4, 2016 - 3.2.3 Managing the Global History Register . ..... Put another way, instructions don't need to spend N cycles moving their way through the fetch ...

Supervisor - GitHub
When given an integer, the supervisor terminates the child process using. Process.exit(child, :shutdown) and waits for an exist signal within the time.

robtarr - GitHub
http://globalmoxie.com/blog/making-of-people-mobile.shtml. Saturday, October ... http://24ways.org/2011/conditional-loading-for-responsive-designs. Saturday ...

MY9221 - GitHub
The MY9221, 12-channels (R/G/B x 4) c o n s t a n t current APDM (Adaptive Pulse Density. Modulation) LED driver, operates over a 3V ~ 5.5V input voltage ...

fpYlll - GitHub
Jul 6, 2017 - fpylll is a Python (2 and 3) library for performing lattice reduction on ... expressiveness and ease-of-use beat raw performance.1. 1Okay, to ... py.test for testing Python. .... GSO complete API for plain Gram-Schmidt objects, all.

article - GitHub
2 Universidad Nacional de Tres de Febrero, Caseros, Argentina. ..... www-nlpir.nist.gov/projects/duc/guidelines/2002.html. 6. .... http://singhal.info/ieee2001.pdf.

PyBioMed - GitHub
calculate ten types of molecular descriptors to represent small molecules, including constitutional descriptors ... charge descriptors, molecular properties, kappa shape indices, MOE-type descriptors, and molecular ... The molecular weight (MW) is th

MOC3063 - GitHub
IF lies between max IFT (15mA for MOC3061M, 10mA for MOC3062M ..... Dual Cool™ ... Fairchild's Anti-Counterfeiting Policy is also stated on ourexternal website, ... Datasheet contains the design specifications for product development.

MLX90615 - GitHub
Nov 8, 2013 - of 0.02°C or via a 10-bit PWM (Pulse Width Modulated) signal from the device. ...... The chip supports a 2 wires serial protocol, build with pins SDA and SCL. ...... measure the temperature profile of the top of the can and keep the pe

Covarep - GitHub
Apr 23, 2014 - Gilles Degottex1, John Kane2, Thomas Drugman3, Tuomo Raitio4, Stefan .... Compile the Covarep.pdf document if Covarep.tex changed.

SeparableFilter11 - GitHub
1. SeparableFilter11. AMD Developer Relations. Overview ... Load the center sample(s) int2 i2KernelCenter ... Macro defines what happens at the kernel center.

Programming - GitHub
Jan 16, 2018 - The second you can only catch by thorough testing (see the HW). 5. Don't use magic numbers. 6. Use meaningful names. Don't do this: data("ChickWeight") out = lm(weight~Time+Chick+Diet, data=ChickWeight). 7. Comment things that aren't c

SoCsploitation - GitHub
Page 2 ... ( everything – {laptops, servers, etc.} ) • Cheap and low power! WTF is a SoC ... %20Advice_for_Shellcode_on_Embedded_Syst ems.pdf. Tell me more! ... didn't destroy one to have pretty pictures… Teridian ..... [email protected].

Datasheet - GitHub
Dec 18, 2014 - Compliant with Android K and L ..... 9.49 SENSORHUB10_REG (37h) . .... DocID026899 Rev 7. 10. Embedded functions register mapping .

Action - GitHub
Task Scheduling for Mobile Robots Using Interval Algebra. Mudrová and Hawes. .... W1. W2. W3. 0.9 action goto W2 from W1. 0.1. Why use an MDP? cost = 54 ...