@pdftron/pdfnet-node 10.3.0-beta → 10.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/node_modules/underscore/LICENSE +23 -0
- package/node_modules/underscore/README.md +28 -0
- package/node_modules/underscore/amd/_apply.js +7 -0
- package/node_modules/underscore/amd/_applyProperty.js +14 -0
- package/node_modules/underscore/amd/_arrayAccessors.js +11 -0
- package/node_modules/underscore/amd/_arrayMutators.js +15 -0
- package/node_modules/underscore/amd/_baseCreate.js +21 -0
- package/node_modules/underscore/amd/_baseIteratee.js +15 -0
- package/node_modules/underscore/amd/_binarySearch.js +17 -0
- package/node_modules/underscore/amd/_bindCb.js +14 -0
- package/node_modules/underscore/amd/_bindCb4.js +17 -0
- package/node_modules/underscore/amd/_byValue.js +11 -0
- package/node_modules/underscore/amd/_cb.js +12 -0
- package/node_modules/underscore/amd/_chainResult.js +10 -0
- package/node_modules/underscore/amd/_collectNonEnumProps.js +42 -0
- package/node_modules/underscore/amd/_createAssigner.js +24 -0
- package/node_modules/underscore/amd/_createEscaper.js +21 -0
- package/node_modules/underscore/amd/_createIndexFinder.js +30 -0
- package/node_modules/underscore/amd/_createPredicateIndexFinder.js +18 -0
- package/node_modules/underscore/amd/_createReduce.js +30 -0
- package/node_modules/underscore/amd/_createSizePropertyCheck.js +13 -0
- package/node_modules/underscore/amd/_deepGet.js +15 -0
- package/node_modules/underscore/amd/_escapeMap.js +15 -0
- package/node_modules/underscore/amd/_executeBound.js +16 -0
- package/node_modules/underscore/amd/_extremum.js +35 -0
- package/node_modules/underscore/amd/_flatten.js +32 -0
- package/node_modules/underscore/amd/_forceNumericMinMax.js +16 -0
- package/node_modules/underscore/amd/_getByteLength.js +8 -0
- package/node_modules/underscore/amd/_getLength.js +8 -0
- package/node_modules/underscore/amd/_greater.js +10 -0
- package/node_modules/underscore/amd/_group.js +18 -0
- package/node_modules/underscore/amd/_has.js +10 -0
- package/node_modules/underscore/amd/_hasObjectTag.js +7 -0
- package/node_modules/underscore/amd/_isArrayLike.js +11 -0
- package/node_modules/underscore/amd/_isBufferLike.js +9 -0
- package/node_modules/underscore/amd/_keyInObj.js +11 -0
- package/node_modules/underscore/amd/_less.js +10 -0
- package/node_modules/underscore/amd/_lessEqual.js +10 -0
- package/node_modules/underscore/amd/_linearSearch.js +31 -0
- package/node_modules/underscore/amd/_mapReduce.js +5 -0
- package/node_modules/underscore/amd/_methodFingerprint.js +44 -0
- package/node_modules/underscore/amd/_optimizeCb.js +27 -0
- package/node_modules/underscore/amd/_push.js +7 -0
- package/node_modules/underscore/amd/_pusher.js +13 -0
- package/node_modules/underscore/amd/_sequence.js +18 -0
- package/node_modules/underscore/amd/_setup.js +70 -0
- package/node_modules/underscore/amd/_shallowProperty.js +12 -0
- package/node_modules/underscore/amd/_slice.js +7 -0
- package/node_modules/underscore/amd/_strictEqual.js +9 -0
- package/node_modules/underscore/amd/_stringTagBug.js +16 -0
- package/node_modules/underscore/amd/_tagTester.js +13 -0
- package/node_modules/underscore/amd/_toBufferView.js +15 -0
- package/node_modules/underscore/amd/_toPath.js +11 -0
- package/node_modules/underscore/amd/_unescapeMap.js +8 -0
- package/node_modules/underscore/amd/_unmethodize.js +9 -0
- package/node_modules/underscore/amd/_wrapArrayAccessor.js +15 -0
- package/node_modules/underscore/amd/_wrapArrayMutator.js +28 -0
- package/node_modules/underscore/amd/after.js +14 -0
- package/node_modules/underscore/amd/allKeys.js +15 -0
- package/node_modules/underscore/amd/before.js +18 -0
- package/node_modules/underscore/amd/bind.js +15 -0
- package/node_modules/underscore/amd/bindAll.js +19 -0
- package/node_modules/underscore/amd/chain.js +12 -0
- package/node_modules/underscore/amd/chunk.js +17 -0
- package/node_modules/underscore/amd/clone.js +11 -0
- package/node_modules/underscore/amd/compact.js +10 -0
- package/node_modules/underscore/amd/compose.js +18 -0
- package/node_modules/underscore/amd/concat.js +7 -0
- package/node_modules/underscore/amd/constant.js +12 -0
- package/node_modules/underscore/amd/contains.js +12 -0
- package/node_modules/underscore/amd/countBy.js +12 -0
- package/node_modules/underscore/amd/create.js +14 -0
- package/node_modules/underscore/amd/debounce.js +43 -0
- package/node_modules/underscore/amd/defaults.js +8 -0
- package/node_modules/underscore/amd/defer.js +9 -0
- package/node_modules/underscore/amd/delay.js +13 -0
- package/node_modules/underscore/amd/difference.js +14 -0
- package/node_modules/underscore/amd/each.js +25 -0
- package/node_modules/underscore/amd/escape.js +8 -0
- package/node_modules/underscore/amd/every.js +17 -0
- package/node_modules/underscore/amd/extend.js +8 -0
- package/node_modules/underscore/amd/extendOwn.js +10 -0
- package/node_modules/underscore/amd/filter.js +15 -0
- package/node_modules/underscore/amd/find.js +12 -0
- package/node_modules/underscore/amd/findIndex.js +8 -0
- package/node_modules/underscore/amd/findKey.js +15 -0
- package/node_modules/underscore/amd/findLastIndex.js +8 -0
- package/node_modules/underscore/amd/findWhere.js +11 -0
- package/node_modules/underscore/amd/first.js +13 -0
- package/node_modules/underscore/amd/flatten.js +11 -0
- package/node_modules/underscore/amd/functions.js +14 -0
- package/node_modules/underscore/amd/get.js +14 -0
- package/node_modules/underscore/amd/groupBy.js +11 -0
- package/node_modules/underscore/amd/has.js +19 -0
- package/node_modules/underscore/amd/identity.js +10 -0
- package/node_modules/underscore/amd/index-default.js +12 -0
- package/node_modules/underscore/amd/index.js +154 -0
- package/node_modules/underscore/amd/indexBy.js +11 -0
- package/node_modules/underscore/amd/indexOf.js +11 -0
- package/node_modules/underscore/amd/initial.js +12 -0
- package/node_modules/underscore/amd/intersection.js +22 -0
- package/node_modules/underscore/amd/invert.js +15 -0
- package/node_modules/underscore/amd/invoke.js +28 -0
- package/node_modules/underscore/amd/isArguments.js +19 -0
- package/node_modules/underscore/amd/isArray.js +9 -0
- package/node_modules/underscore/amd/isArrayBuffer.js +7 -0
- package/node_modules/underscore/amd/isBoolean.js +10 -0
- package/node_modules/underscore/amd/isDataView.js +15 -0
- package/node_modules/underscore/amd/isDate.js +7 -0
- package/node_modules/underscore/amd/isElement.js +10 -0
- package/node_modules/underscore/amd/isEmpty.js +18 -0
- package/node_modules/underscore/amd/isEqual.js +133 -0
- package/node_modules/underscore/amd/isError.js +7 -0
- package/node_modules/underscore/amd/isFinite.js +10 -0
- package/node_modules/underscore/amd/isFunction.js +18 -0
- package/node_modules/underscore/amd/isMap.js +7 -0
- package/node_modules/underscore/amd/isMatch.js +17 -0
- package/node_modules/underscore/amd/isNaN.js +10 -0
- package/node_modules/underscore/amd/isNull.js +10 -0
- package/node_modules/underscore/amd/isNumber.js +7 -0
- package/node_modules/underscore/amd/isObject.js +11 -0
- package/node_modules/underscore/amd/isRegExp.js +7 -0
- package/node_modules/underscore/amd/isSet.js +7 -0
- package/node_modules/underscore/amd/isString.js +7 -0
- package/node_modules/underscore/amd/isSymbol.js +7 -0
- package/node_modules/underscore/amd/isTypedArray.js +16 -0
- package/node_modules/underscore/amd/isUndefined.js +10 -0
- package/node_modules/underscore/amd/isWeakMap.js +7 -0
- package/node_modules/underscore/amd/isWeakSet.js +7 -0
- package/node_modules/underscore/amd/iteratee.js +13 -0
- package/node_modules/underscore/amd/join.js +7 -0
- package/node_modules/underscore/amd/keys.js +17 -0
- package/node_modules/underscore/amd/last.js +13 -0
- package/node_modules/underscore/amd/lastIndexOf.js +9 -0
- package/node_modules/underscore/amd/map.js +18 -0
- package/node_modules/underscore/amd/mapObject.js +19 -0
- package/node_modules/underscore/amd/matcher.js +14 -0
- package/node_modules/underscore/amd/max.js +30 -0
- package/node_modules/underscore/amd/memoize.js +17 -0
- package/node_modules/underscore/amd/min.js +30 -0
- package/node_modules/underscore/amd/mixin.js +18 -0
- package/node_modules/underscore/amd/negate.js +12 -0
- package/node_modules/underscore/amd/noop.js +8 -0
- package/node_modules/underscore/amd/now.js +10 -0
- package/node_modules/underscore/amd/object.js +20 -0
- package/node_modules/underscore/amd/omit.js +20 -0
- package/node_modules/underscore/amd/once.js +9 -0
- package/node_modules/underscore/amd/pairs.js +17 -0
- package/node_modules/underscore/amd/partial.js +25 -0
- package/node_modules/underscore/amd/partition.js +11 -0
- package/node_modules/underscore/amd/pick.js +25 -0
- package/node_modules/underscore/amd/pluck.js +10 -0
- package/node_modules/underscore/amd/pop.js +7 -0
- package/node_modules/underscore/amd/property.js +14 -0
- package/node_modules/underscore/amd/propertyOf.js +13 -0
- package/node_modules/underscore/amd/push.js +7 -0
- package/node_modules/underscore/amd/random.js +14 -0
- package/node_modules/underscore/amd/range.js +27 -0
- package/node_modules/underscore/amd/reduce.js +9 -0
- package/node_modules/underscore/amd/reduceRight.js +8 -0
- package/node_modules/underscore/amd/reject.js +10 -0
- package/node_modules/underscore/amd/rest.js +12 -0
- package/node_modules/underscore/amd/restArguments.js +33 -0
- package/node_modules/underscore/amd/result.js +25 -0
- package/node_modules/underscore/amd/reverse.js +7 -0
- package/node_modules/underscore/amd/sample.js +27 -0
- package/node_modules/underscore/amd/shift.js +7 -0
- package/node_modules/underscore/amd/shuffle.js +10 -0
- package/node_modules/underscore/amd/size.js +11 -0
- package/node_modules/underscore/amd/slice.js +7 -0
- package/node_modules/underscore/amd/some.js +17 -0
- package/node_modules/underscore/amd/sort.js +7 -0
- package/node_modules/underscore/amd/sortBy.js +26 -0
- package/node_modules/underscore/amd/sortedIndex.js +18 -0
- package/node_modules/underscore/amd/sortedLastIndex.js +11 -0
- package/node_modules/underscore/amd/splice.js +7 -0
- package/node_modules/underscore/amd/tap.js +13 -0
- package/node_modules/underscore/amd/template.js +95 -0
- package/node_modules/underscore/amd/templateSettings.js +13 -0
- package/node_modules/underscore/amd/throttle.js +51 -0
- package/node_modules/underscore/amd/times.js +13 -0
- package/node_modules/underscore/amd/toArray.js +18 -0
- package/node_modules/underscore/amd/toPath.js +12 -0
- package/node_modules/underscore/amd/toString.js +11 -0
- package/node_modules/underscore/amd/underscore-array-methods.js +30 -0
- package/node_modules/underscore/amd/underscore.js +29 -0
- package/node_modules/underscore/amd/unescape.js +8 -0
- package/node_modules/underscore/amd/union.js +11 -0
- package/node_modules/underscore/amd/uniq.js +37 -0
- package/node_modules/underscore/amd/uniqueId.js +13 -0
- package/node_modules/underscore/amd/unshift.js +7 -0
- package/node_modules/underscore/amd/unzip.js +17 -0
- package/node_modules/underscore/amd/value.js +13 -0
- package/node_modules/underscore/amd/values.js +16 -0
- package/node_modules/underscore/amd/where.js +11 -0
- package/node_modules/underscore/amd/without.js +10 -0
- package/node_modules/underscore/amd/wrap.js +12 -0
- package/node_modules/underscore/amd/zip.js +9 -0
- package/node_modules/underscore/cjs/_apply.js +6 -0
- package/node_modules/underscore/cjs/_applyProperty.js +10 -0
- package/node_modules/underscore/cjs/_arrayAccessors.js +11 -0
- package/node_modules/underscore/cjs/_arrayMutators.js +19 -0
- package/node_modules/underscore/cjs/_baseCreate.js +20 -0
- package/node_modules/underscore/cjs/_baseIteratee.js +19 -0
- package/node_modules/underscore/cjs/_binarySearch.js +15 -0
- package/node_modules/underscore/cjs/_bindCb.js +10 -0
- package/node_modules/underscore/cjs/_bindCb4.js +13 -0
- package/node_modules/underscore/cjs/_byValue.js +7 -0
- package/node_modules/underscore/cjs/_cb.js +12 -0
- package/node_modules/underscore/cjs/_chainResult.js +8 -0
- package/node_modules/underscore/cjs/_collectNonEnumProps.js +42 -0
- package/node_modules/underscore/cjs/_createAssigner.js +20 -0
- package/node_modules/underscore/cjs/_createEscaper.js +19 -0
- package/node_modules/underscore/cjs/_createIndexFinder.js +30 -0
- package/node_modules/underscore/cjs/_createPredicateIndexFinder.js +17 -0
- package/node_modules/underscore/cjs/_createReduce.js +30 -0
- package/node_modules/underscore/cjs/_createSizePropertyCheck.js +11 -0
- package/node_modules/underscore/cjs/_deepGet.js +11 -0
- package/node_modules/underscore/cjs/_escapeMap.js +11 -0
- package/node_modules/underscore/cjs/_executeBound.js +15 -0
- package/node_modules/underscore/cjs/_extremum.js +35 -0
- package/node_modules/underscore/cjs/_flatten.js +33 -0
- package/node_modules/underscore/cjs/_forceNumericMinMax.js +14 -0
- package/node_modules/underscore/cjs/_getByteLength.js +6 -0
- package/node_modules/underscore/cjs/_getLength.js +6 -0
- package/node_modules/underscore/cjs/_greater.js +6 -0
- package/node_modules/underscore/cjs/_group.js +17 -0
- package/node_modules/underscore/cjs/_has.js +8 -0
- package/node_modules/underscore/cjs/_hasObjectTag.js +5 -0
- package/node_modules/underscore/cjs/_isArrayLike.js +10 -0
- package/node_modules/underscore/cjs/_isBufferLike.js +8 -0
- package/node_modules/underscore/cjs/_keyInObj.js +7 -0
- package/node_modules/underscore/cjs/_less.js +6 -0
- package/node_modules/underscore/cjs/_lessEqual.js +6 -0
- package/node_modules/underscore/cjs/_linearSearch.js +30 -0
- package/node_modules/underscore/cjs/_mapReduce.js +1 -0
- package/node_modules/underscore/cjs/_methodFingerprint.js +44 -0
- package/node_modules/underscore/cjs/_optimizeCb.js +23 -0
- package/node_modules/underscore/cjs/_push.js +6 -0
- package/node_modules/underscore/cjs/_pusher.js +9 -0
- package/node_modules/underscore/cjs/_sequence.js +14 -0
- package/node_modules/underscore/cjs/_setup.js +66 -0
- package/node_modules/underscore/cjs/_shallowProperty.js +8 -0
- package/node_modules/underscore/cjs/_slice.js +6 -0
- package/node_modules/underscore/cjs/_strictEqual.js +5 -0
- package/node_modules/underscore/cjs/_stringTagBug.js +15 -0
- package/node_modules/underscore/cjs/_tagTester.js +11 -0
- package/node_modules/underscore/cjs/_toBufferView.js +13 -0
- package/node_modules/underscore/cjs/_toPath.js +10 -0
- package/node_modules/underscore/cjs/_unescapeMap.js +7 -0
- package/node_modules/underscore/cjs/_unmethodize.js +8 -0
- package/node_modules/underscore/cjs/_wrapArrayAccessor.js +14 -0
- package/node_modules/underscore/cjs/_wrapArrayMutator.js +29 -0
- package/node_modules/underscore/cjs/after.js +10 -0
- package/node_modules/underscore/cjs/allKeys.js +15 -0
- package/node_modules/underscore/cjs/before.js +14 -0
- package/node_modules/underscore/cjs/bind.js +15 -0
- package/node_modules/underscore/cjs/bindAll.js +19 -0
- package/node_modules/underscore/cjs/chain.js +10 -0
- package/node_modules/underscore/cjs/chunk.js +15 -0
- package/node_modules/underscore/cjs/clone.js +11 -0
- package/node_modules/underscore/cjs/compact.js +8 -0
- package/node_modules/underscore/cjs/compose.js +14 -0
- package/node_modules/underscore/cjs/concat.js +6 -0
- package/node_modules/underscore/cjs/constant.js +8 -0
- package/node_modules/underscore/cjs/contains.js +12 -0
- package/node_modules/underscore/cjs/countBy.js +11 -0
- package/node_modules/underscore/cjs/create.js +13 -0
- package/node_modules/underscore/cjs/debounce.js +42 -0
- package/node_modules/underscore/cjs/defaults.js +7 -0
- package/node_modules/underscore/cjs/defer.js +9 -0
- package/node_modules/underscore/cjs/delay.js +11 -0
- package/node_modules/underscore/cjs/difference.js +15 -0
- package/node_modules/underscore/cjs/each.js +25 -0
- package/node_modules/underscore/cjs/escape.js +7 -0
- package/node_modules/underscore/cjs/every.js +17 -0
- package/node_modules/underscore/cjs/extend.js +7 -0
- package/node_modules/underscore/cjs/extendOwn.js +9 -0
- package/node_modules/underscore/cjs/filter.js +14 -0
- package/node_modules/underscore/cjs/find.js +12 -0
- package/node_modules/underscore/cjs/findIndex.js +6 -0
- package/node_modules/underscore/cjs/findKey.js +14 -0
- package/node_modules/underscore/cjs/findLastIndex.js +6 -0
- package/node_modules/underscore/cjs/findWhere.js +10 -0
- package/node_modules/underscore/cjs/first.js +11 -0
- package/node_modules/underscore/cjs/flatten.js +9 -0
- package/node_modules/underscore/cjs/functions.js +12 -0
- package/node_modules/underscore/cjs/get.js +14 -0
- package/node_modules/underscore/cjs/groupBy.js +10 -0
- package/node_modules/underscore/cjs/has.js +18 -0
- package/node_modules/underscore/cjs/identity.js +6 -0
- package/node_modules/underscore/cjs/index-default.js +11 -0
- package/node_modules/underscore/cjs/index.js +277 -0
- package/node_modules/underscore/cjs/indexBy.js +9 -0
- package/node_modules/underscore/cjs/indexOf.js +11 -0
- package/node_modules/underscore/cjs/initial.js +10 -0
- package/node_modules/underscore/cjs/intersection.js +21 -0
- package/node_modules/underscore/cjs/invert.js +13 -0
- package/node_modules/underscore/cjs/invoke.js +30 -0
- package/node_modules/underscore/cjs/isArguments.js +18 -0
- package/node_modules/underscore/cjs/isArray.js +8 -0
- package/node_modules/underscore/cjs/isArrayBuffer.js +5 -0
- package/node_modules/underscore/cjs/isBoolean.js +8 -0
- package/node_modules/underscore/cjs/isDataView.js +16 -0
- package/node_modules/underscore/cjs/isDate.js +5 -0
- package/node_modules/underscore/cjs/isElement.js +6 -0
- package/node_modules/underscore/cjs/isEmpty.js +20 -0
- package/node_modules/underscore/cjs/isEqual.js +140 -0
- package/node_modules/underscore/cjs/isError.js +5 -0
- package/node_modules/underscore/cjs/isFinite.js +9 -0
- package/node_modules/underscore/cjs/isFunction.js +17 -0
- package/node_modules/underscore/cjs/isMap.js +7 -0
- package/node_modules/underscore/cjs/isMatch.js +15 -0
- package/node_modules/underscore/cjs/isNaN.js +9 -0
- package/node_modules/underscore/cjs/isNull.js +6 -0
- package/node_modules/underscore/cjs/isNumber.js +5 -0
- package/node_modules/underscore/cjs/isObject.js +7 -0
- package/node_modules/underscore/cjs/isRegExp.js +5 -0
- package/node_modules/underscore/cjs/isSet.js +7 -0
- package/node_modules/underscore/cjs/isString.js +5 -0
- package/node_modules/underscore/cjs/isSymbol.js +5 -0
- package/node_modules/underscore/cjs/isTypedArray.js +17 -0
- package/node_modules/underscore/cjs/isUndefined.js +6 -0
- package/node_modules/underscore/cjs/isWeakMap.js +7 -0
- package/node_modules/underscore/cjs/isWeakSet.js +5 -0
- package/node_modules/underscore/cjs/iteratee.js +12 -0
- package/node_modules/underscore/cjs/join.js +6 -0
- package/node_modules/underscore/cjs/keys.js +18 -0
- package/node_modules/underscore/cjs/last.js +11 -0
- package/node_modules/underscore/cjs/lastIndexOf.js +8 -0
- package/node_modules/underscore/cjs/map.js +18 -0
- package/node_modules/underscore/cjs/mapObject.js +18 -0
- package/node_modules/underscore/cjs/matcher.js +13 -0
- package/node_modules/underscore/cjs/max.js +31 -0
- package/node_modules/underscore/cjs/memoize.js +15 -0
- package/node_modules/underscore/cjs/min.js +31 -0
- package/node_modules/underscore/cjs/mixin.js +20 -0
- package/node_modules/underscore/cjs/negate.js +8 -0
- package/node_modules/underscore/cjs/noop.js +4 -0
- package/node_modules/underscore/cjs/now.js +6 -0
- package/node_modules/underscore/cjs/object.js +18 -0
- package/node_modules/underscore/cjs/omit.js +24 -0
- package/node_modules/underscore/cjs/once.js +8 -0
- package/node_modules/underscore/cjs/pairs.js +15 -0
- package/node_modules/underscore/cjs/partial.js +25 -0
- package/node_modules/underscore/cjs/partition.js +9 -0
- package/node_modules/underscore/cjs/pick.js +28 -0
- package/node_modules/underscore/cjs/pluck.js +9 -0
- package/node_modules/underscore/cjs/pop.js +6 -0
- package/node_modules/underscore/cjs/property.js +13 -0
- package/node_modules/underscore/cjs/propertyOf.js +12 -0
- package/node_modules/underscore/cjs/push.js +6 -0
- package/node_modules/underscore/cjs/random.js +10 -0
- package/node_modules/underscore/cjs/range.js +23 -0
- package/node_modules/underscore/cjs/reduce.js +7 -0
- package/node_modules/underscore/cjs/reduceRight.js +6 -0
- package/node_modules/underscore/cjs/reject.js +10 -0
- package/node_modules/underscore/cjs/rest.js +10 -0
- package/node_modules/underscore/cjs/restArguments.js +29 -0
- package/node_modules/underscore/cjs/result.js +24 -0
- package/node_modules/underscore/cjs/reverse.js +6 -0
- package/node_modules/underscore/cjs/sample.js +29 -0
- package/node_modules/underscore/cjs/shift.js +6 -0
- package/node_modules/underscore/cjs/shuffle.js +8 -0
- package/node_modules/underscore/cjs/size.js +10 -0
- package/node_modules/underscore/cjs/slice.js +6 -0
- package/node_modules/underscore/cjs/some.js +17 -0
- package/node_modules/underscore/cjs/sort.js +6 -0
- package/node_modules/underscore/cjs/sortBy.js +26 -0
- package/node_modules/underscore/cjs/sortedIndex.js +17 -0
- package/node_modules/underscore/cjs/sortedLastIndex.js +11 -0
- package/node_modules/underscore/cjs/splice.js +6 -0
- package/node_modules/underscore/cjs/tap.js +9 -0
- package/node_modules/underscore/cjs/template.js +95 -0
- package/node_modules/underscore/cjs/templateSettings.js +11 -0
- package/node_modules/underscore/cjs/throttle.js +49 -0
- package/node_modules/underscore/cjs/times.js +11 -0
- package/node_modules/underscore/cjs/toArray.js +22 -0
- package/node_modules/underscore/cjs/toPath.js +11 -0
- package/node_modules/underscore/cjs/toString.js +9 -0
- package/node_modules/underscore/cjs/underscore-array-methods.js +31 -0
- package/node_modules/underscore/cjs/underscore.js +27 -0
- package/node_modules/underscore/cjs/unescape.js +7 -0
- package/node_modules/underscore/cjs/union.js +11 -0
- package/node_modules/underscore/cjs/uniq.js +38 -0
- package/node_modules/underscore/cjs/uniqueId.js +9 -0
- package/node_modules/underscore/cjs/unshift.js +6 -0
- package/node_modules/underscore/cjs/unzip.js +17 -0
- package/node_modules/underscore/cjs/value.js +9 -0
- package/node_modules/underscore/cjs/values.js +14 -0
- package/node_modules/underscore/cjs/where.js +10 -0
- package/node_modules/underscore/cjs/without.js +9 -0
- package/node_modules/underscore/cjs/wrap.js +10 -0
- package/node_modules/underscore/cjs/zip.js +8 -0
- package/node_modules/underscore/modules/.eslintrc +12 -0
- package/node_modules/underscore/modules/_baseCreate.js +18 -0
- package/node_modules/underscore/modules/_baseIteratee.js +17 -0
- package/node_modules/underscore/modules/_cb.js +10 -0
- package/node_modules/underscore/modules/_chainResult.js +6 -0
- package/node_modules/underscore/modules/_collectNonEnumProps.js +40 -0
- package/node_modules/underscore/modules/_createAssigner.js +18 -0
- package/node_modules/underscore/modules/_createEscaper.js +17 -0
- package/node_modules/underscore/modules/_createIndexFinder.js +28 -0
- package/node_modules/underscore/modules/_createPredicateIndexFinder.js +15 -0
- package/node_modules/underscore/modules/_createReduce.js +28 -0
- package/node_modules/underscore/modules/_createSizePropertyCheck.js +9 -0
- package/node_modules/underscore/modules/_deepGet.js +9 -0
- package/node_modules/underscore/modules/_escapeMap.js +9 -0
- package/node_modules/underscore/modules/_executeBound.js +13 -0
- package/node_modules/underscore/modules/_flatten.js +31 -0
- package/node_modules/underscore/modules/_getByteLength.js +4 -0
- package/node_modules/underscore/modules/_getLength.js +4 -0
- package/node_modules/underscore/modules/_group.js +15 -0
- package/node_modules/underscore/modules/_has.js +6 -0
- package/node_modules/underscore/modules/_hasObjectTag.js +3 -0
- package/node_modules/underscore/modules/_isArrayLike.js +8 -0
- package/node_modules/underscore/modules/_isBufferLike.js +6 -0
- package/node_modules/underscore/modules/_keyInObj.js +5 -0
- package/node_modules/underscore/modules/_methodFingerprint.js +37 -0
- package/node_modules/underscore/modules/_optimizeCb.js +21 -0
- package/node_modules/underscore/modules/_setup.js +43 -0
- package/node_modules/underscore/modules/_shallowProperty.js +6 -0
- package/node_modules/underscore/modules/_stringTagBug.js +10 -0
- package/node_modules/underscore/modules/_tagTester.js +9 -0
- package/node_modules/underscore/modules/_toBufferView.js +11 -0
- package/node_modules/underscore/modules/_toPath.js +8 -0
- package/node_modules/underscore/modules/_unescapeMap.js +5 -0
- package/node_modules/underscore/modules/after.js +8 -0
- package/node_modules/underscore/modules/allKeys.js +13 -0
- package/node_modules/underscore/modules/before.js +12 -0
- package/node_modules/underscore/modules/bind.js +13 -0
- package/node_modules/underscore/modules/bindAll.js +17 -0
- package/node_modules/underscore/modules/chain.js +8 -0
- package/node_modules/underscore/modules/chunk.js +13 -0
- package/node_modules/underscore/modules/clone.js +9 -0
- package/node_modules/underscore/modules/compact.js +6 -0
- package/node_modules/underscore/modules/compose.js +12 -0
- package/node_modules/underscore/modules/constant.js +6 -0
- package/node_modules/underscore/modules/contains.js +10 -0
- package/node_modules/underscore/modules/countBy.js +9 -0
- package/node_modules/underscore/modules/create.js +11 -0
- package/node_modules/underscore/modules/debounce.js +40 -0
- package/node_modules/underscore/modules/defaults.js +5 -0
- package/node_modules/underscore/modules/defer.js +7 -0
- package/node_modules/underscore/modules/delay.js +9 -0
- package/node_modules/underscore/modules/difference.js +13 -0
- package/node_modules/underscore/modules/each.js +23 -0
- package/node_modules/underscore/modules/escape.js +5 -0
- package/node_modules/underscore/modules/every.js +15 -0
- package/node_modules/underscore/modules/extend.js +5 -0
- package/node_modules/underscore/modules/extendOwn.js +7 -0
- package/node_modules/underscore/modules/filter.js +12 -0
- package/node_modules/underscore/modules/find.js +10 -0
- package/node_modules/underscore/modules/findIndex.js +4 -0
- package/node_modules/underscore/modules/findKey.js +12 -0
- package/node_modules/underscore/modules/findLastIndex.js +4 -0
- package/node_modules/underscore/modules/findWhere.js +8 -0
- package/node_modules/underscore/modules/first.js +9 -0
- package/node_modules/underscore/modules/flatten.js +7 -0
- package/node_modules/underscore/modules/functions.js +10 -0
- package/node_modules/underscore/modules/get.js +12 -0
- package/node_modules/underscore/modules/groupBy.js +8 -0
- package/node_modules/underscore/modules/has.js +16 -0
- package/node_modules/underscore/modules/identity.js +4 -0
- package/node_modules/underscore/modules/index-all.js +18 -0
- package/node_modules/underscore/modules/index-default.js +27 -0
- package/node_modules/underscore/modules/index.js +200 -0
- package/node_modules/underscore/modules/indexBy.js +7 -0
- package/node_modules/underscore/modules/indexOf.js +9 -0
- package/node_modules/underscore/modules/initial.js +8 -0
- package/node_modules/underscore/modules/intersection.js +19 -0
- package/node_modules/underscore/modules/invert.js +11 -0
- package/node_modules/underscore/modules/invoke.js +28 -0
- package/node_modules/underscore/modules/isArguments.js +16 -0
- package/node_modules/underscore/modules/isArray.js +6 -0
- package/node_modules/underscore/modules/isArrayBuffer.js +3 -0
- package/node_modules/underscore/modules/isBoolean.js +6 -0
- package/node_modules/underscore/modules/isDataView.js +14 -0
- package/node_modules/underscore/modules/isDate.js +3 -0
- package/node_modules/underscore/modules/isElement.js +4 -0
- package/node_modules/underscore/modules/isEmpty.js +18 -0
- package/node_modules/underscore/modules/isEqual.js +138 -0
- package/node_modules/underscore/modules/isError.js +3 -0
- package/node_modules/underscore/modules/isFinite.js +7 -0
- package/node_modules/underscore/modules/isFunction.js +15 -0
- package/node_modules/underscore/modules/isMap.js +5 -0
- package/node_modules/underscore/modules/isMatch.js +13 -0
- package/node_modules/underscore/modules/isNaN.js +7 -0
- package/node_modules/underscore/modules/isNull.js +4 -0
- package/node_modules/underscore/modules/isNumber.js +3 -0
- package/node_modules/underscore/modules/isObject.js +5 -0
- package/node_modules/underscore/modules/isRegExp.js +3 -0
- package/node_modules/underscore/modules/isSet.js +5 -0
- package/node_modules/underscore/modules/isString.js +3 -0
- package/node_modules/underscore/modules/isSymbol.js +3 -0
- package/node_modules/underscore/modules/isTypedArray.js +15 -0
- package/node_modules/underscore/modules/isUndefined.js +4 -0
- package/node_modules/underscore/modules/isWeakMap.js +5 -0
- package/node_modules/underscore/modules/isWeakSet.js +3 -0
- package/node_modules/underscore/modules/iteratee.js +10 -0
- package/node_modules/underscore/modules/keys.js +16 -0
- package/node_modules/underscore/modules/last.js +9 -0
- package/node_modules/underscore/modules/lastIndexOf.js +6 -0
- package/node_modules/underscore/modules/map.js +16 -0
- package/node_modules/underscore/modules/mapObject.js +16 -0
- package/node_modules/underscore/modules/matcher.js +11 -0
- package/node_modules/underscore/modules/max.js +29 -0
- package/node_modules/underscore/modules/memoize.js +13 -0
- package/node_modules/underscore/modules/min.js +29 -0
- package/node_modules/underscore/modules/mixin.js +18 -0
- package/node_modules/underscore/modules/negate.js +6 -0
- package/node_modules/underscore/modules/noop.js +2 -0
- package/node_modules/underscore/modules/now.js +4 -0
- package/node_modules/underscore/modules/object.js +16 -0
- package/node_modules/underscore/modules/omit.js +22 -0
- package/node_modules/underscore/modules/once.js +6 -0
- package/node_modules/underscore/modules/pairs.js +13 -0
- package/node_modules/underscore/modules/partial.js +24 -0
- package/node_modules/underscore/modules/partition.js +7 -0
- package/node_modules/underscore/modules/pick.js +26 -0
- package/node_modules/underscore/modules/pluck.js +7 -0
- package/node_modules/underscore/modules/property.js +11 -0
- package/node_modules/underscore/modules/propertyOf.js +10 -0
- package/node_modules/underscore/modules/random.js +8 -0
- package/node_modules/underscore/modules/range.js +21 -0
- package/node_modules/underscore/modules/reduce.js +5 -0
- package/node_modules/underscore/modules/reduceRight.js +4 -0
- package/node_modules/underscore/modules/reject.js +8 -0
- package/node_modules/underscore/modules/rest.js +8 -0
- package/node_modules/underscore/modules/restArguments.js +27 -0
- package/node_modules/underscore/modules/result.js +22 -0
- package/node_modules/underscore/modules/sample.js +27 -0
- package/node_modules/underscore/modules/shuffle.js +6 -0
- package/node_modules/underscore/modules/size.js +8 -0
- package/node_modules/underscore/modules/some.js +15 -0
- package/node_modules/underscore/modules/sortBy.js +24 -0
- package/node_modules/underscore/modules/sortedIndex.js +15 -0
- package/node_modules/underscore/modules/tap.js +7 -0
- package/node_modules/underscore/modules/template.js +93 -0
- package/node_modules/underscore/modules/templateSettings.js +9 -0
- package/node_modules/underscore/modules/throttle.js +47 -0
- package/node_modules/underscore/modules/times.js +9 -0
- package/node_modules/underscore/modules/toArray.js +20 -0
- package/node_modules/underscore/modules/toPath.js +9 -0
- package/node_modules/underscore/modules/underscore-array-methods.js +31 -0
- package/node_modules/underscore/modules/underscore.js +25 -0
- package/node_modules/underscore/modules/unescape.js +5 -0
- package/node_modules/underscore/modules/union.js +9 -0
- package/node_modules/underscore/modules/uniq.js +36 -0
- package/node_modules/underscore/modules/uniqueId.js +7 -0
- package/node_modules/underscore/modules/unzip.js +15 -0
- package/node_modules/underscore/modules/values.js +12 -0
- package/node_modules/underscore/modules/where.js +8 -0
- package/node_modules/underscore/modules/without.js +7 -0
- package/node_modules/underscore/modules/wrap.js +8 -0
- package/node_modules/underscore/modules/zip.js +6 -0
- package/node_modules/underscore/package.json +108 -0
- package/node_modules/underscore/underscore-esm-min.js +5 -0
- package/node_modules/underscore/underscore-esm-min.js.map +1 -0
- package/node_modules/underscore/underscore-esm.js +2026 -0
- package/node_modules/underscore/underscore-esm.js.map +1 -0
- package/node_modules/underscore/underscore-min.js +6 -0
- package/node_modules/underscore/underscore.js +2034 -0
- package/node_modules/underscore/underscore.js.map +1 -0
- package/node_modules/xhr2/CONTRIBUTING.md +33 -0
- package/node_modules/xhr2/Cakefile +131 -0
- package/node_modules/xhr2/LICENSE.txt +19 -0
- package/node_modules/xhr2/lib/browser.js +1 -0
- package/node_modules/xhr2/lib/xhr2.js +1244 -0
- package/node_modules/xhr2/package.json +93 -0
- package/node_modules/xhr2/src/001-xml_http_request.coffee +782 -0
- package/node_modules/xhr2/src/errors.coffee +31 -0
- package/node_modules/xhr2/src/progress_event.coffee +39 -0
- package/node_modules/xhr2/test/fixtures/hello.json +1 -0
- package/node_modules/xhr2/test/fixtures/hello.txt +1 -0
- package/node_modules/xhr2/test/fixtures/xhr2.png +0 -0
- package/node_modules/xhr2/test/html/browser_test.html +30 -0
- package/node_modules/xhr2/test/src/event_target_test.coffee +85 -0
- package/node_modules/xhr2/test/src/events_test.coffee +204 -0
- package/node_modules/xhr2/test/src/headers_test.coffee +165 -0
- package/node_modules/xhr2/test/src/helpers/browser_mocha_setup.coffee +1 -0
- package/node_modules/xhr2/test/src/helpers/setup.coffee +38 -0
- package/node_modules/xhr2/test/src/helpers/xhr_server.coffee +156 -0
- package/node_modules/xhr2/test/src/nodejs_set_test.coffee +162 -0
- package/node_modules/xhr2/test/src/redirect_test.coffee +57 -0
- package/node_modules/xhr2/test/src/response_type_test.coffee +88 -0
- package/node_modules/xhr2/test/src/send_test.coffee +89 -0
- package/node_modules/xhr2/test/src/status_test.coffee +47 -0
- package/node_modules/xhr2/test/src/xhr_test.coffee +102 -0
- package/package.json +1 -1
|
@@ -0,0 +1,782 @@
|
|
|
1
|
+
# This file's name is set up in such a way that it will always show up second
|
|
2
|
+
# in the list of files given to coffee --join, so it can use the
|
|
3
|
+
# XMLHttpRequestEventTarget definition and so that the other files can assume
|
|
4
|
+
# that XMLHttpRequest was already defined.
|
|
5
|
+
|
|
6
|
+
http = require 'http'
|
|
7
|
+
https = require 'https'
|
|
8
|
+
os = require 'os'
|
|
9
|
+
url = require 'url'
|
|
10
|
+
|
|
11
|
+
# The ECMAScript HTTP API.
|
|
12
|
+
#
|
|
13
|
+
# @see http://www.w3.org/TR/XMLHttpRequest/#introduction
|
|
14
|
+
class XMLHttpRequest extends XMLHttpRequestEventTarget
|
|
15
|
+
# Creates a new request.
|
|
16
|
+
#
|
|
17
|
+
# @param {Object} options one or more of the options below
|
|
18
|
+
# @option options {Boolean} anon if true, the request's anonymous flag
|
|
19
|
+
# will be set
|
|
20
|
+
# @see http://www.w3.org/TR/XMLHttpRequest/#constructors
|
|
21
|
+
# @see http://www.w3.org/TR/XMLHttpRequest/#anonymous-flag
|
|
22
|
+
constructor: (options) ->
|
|
23
|
+
super()
|
|
24
|
+
@onreadystatechange = null
|
|
25
|
+
|
|
26
|
+
@_anonymous = options and options.anon
|
|
27
|
+
|
|
28
|
+
@readyState = XMLHttpRequest.UNSENT
|
|
29
|
+
@response = null
|
|
30
|
+
@responseText = ''
|
|
31
|
+
@responseType = ''
|
|
32
|
+
@responseURL = ''
|
|
33
|
+
@status = 0
|
|
34
|
+
@statusText = ''
|
|
35
|
+
@timeout = 0
|
|
36
|
+
@upload = new XMLHttpRequestUpload @
|
|
37
|
+
|
|
38
|
+
@_method = null # String
|
|
39
|
+
@_url = null # Return value of url.parse()
|
|
40
|
+
@_sync = false
|
|
41
|
+
@_headers = null # Object<String, String>
|
|
42
|
+
@_loweredHeaders = null # Object<lowercase String, String>
|
|
43
|
+
@_mimeOverride = null
|
|
44
|
+
@_request = null # http.ClientRequest
|
|
45
|
+
@_response = null # http.ClientResponse
|
|
46
|
+
@_responseParts = null # Array<Buffer, String>
|
|
47
|
+
@_responseHeaders = null # Object<lowercase String, String>
|
|
48
|
+
@_aborting = null
|
|
49
|
+
@_error = null
|
|
50
|
+
@_loadedBytes = 0
|
|
51
|
+
@_totalBytes = 0
|
|
52
|
+
@_lengthComputable = false
|
|
53
|
+
|
|
54
|
+
# @property {function(ProgressEvent)} DOM level 0-style handler for the
|
|
55
|
+
# 'readystatechange' event
|
|
56
|
+
onreadystatechange: null
|
|
57
|
+
|
|
58
|
+
# @property {Number} the current state of the XHR object
|
|
59
|
+
# @see http://www.w3.org/TR/XMLHttpRequest/#states
|
|
60
|
+
readyState: null
|
|
61
|
+
|
|
62
|
+
# @property {String, ArrayBuffer, Buffer, Object} processed XHR response
|
|
63
|
+
# @see http://www.w3.org/TR/XMLHttpRequest/#the-response-attribute
|
|
64
|
+
response: null
|
|
65
|
+
|
|
66
|
+
# @property {String} response string, if responseType is '' or 'text'
|
|
67
|
+
# @see http://www.w3.org/TR/XMLHttpRequest/#the-responsetext-attribute
|
|
68
|
+
responseText: null
|
|
69
|
+
|
|
70
|
+
# @property {String} sets the parsing method for the XHR response
|
|
71
|
+
# @see http://www.w3.org/TR/XMLHttpRequest/#the-responsetype-attribute
|
|
72
|
+
responseType: null
|
|
73
|
+
|
|
74
|
+
# @property {Number} the HTTP
|
|
75
|
+
# @see http://www.w3.org/TR/XMLHttpRequest/#the-status-attribute
|
|
76
|
+
status: null
|
|
77
|
+
|
|
78
|
+
# @property {Number} milliseconds to wait for the request to complete
|
|
79
|
+
# @see http://www.w3.org/TR/XMLHttpRequest/#the-timeout-attribute
|
|
80
|
+
timeout: null
|
|
81
|
+
|
|
82
|
+
# @property {XMLHttpRequestUpload} the associated upload information
|
|
83
|
+
# @see http://www.w3.org/TR/XMLHttpRequest/#the-upload-attribute
|
|
84
|
+
upload: null
|
|
85
|
+
|
|
86
|
+
# Sets the XHR's method, URL, synchronous flag, and authentication params.
|
|
87
|
+
#
|
|
88
|
+
# @param {String} method the HTTP method to be used
|
|
89
|
+
# @param {String} url the URL that the request will be made to
|
|
90
|
+
# @param {?Boolean} async if false, the XHR should be processed
|
|
91
|
+
# synchronously; true by default
|
|
92
|
+
# @param {?String} user the user credential to be used in HTTP basic
|
|
93
|
+
# authentication
|
|
94
|
+
# @param {?String} password the password credential to be used in HTTP basic
|
|
95
|
+
# authentication
|
|
96
|
+
# @return {undefined} undefined
|
|
97
|
+
# @throw {SecurityError} method is not one of the allowed methods
|
|
98
|
+
# @throw {SyntaxError} urlString is not a valid URL
|
|
99
|
+
# @throw {Error} the URL contains an unsupported protocol; the supported
|
|
100
|
+
# protocols are file, http and https
|
|
101
|
+
# @see http://www.w3.org/TR/XMLHttpRequest/#the-open()-method
|
|
102
|
+
open: (method, url, async, user, password) ->
|
|
103
|
+
method = method.toUpperCase()
|
|
104
|
+
if method of @_restrictedMethods
|
|
105
|
+
throw new SecurityError "HTTP method #{method} is not allowed in XHR"
|
|
106
|
+
|
|
107
|
+
xhrUrl = @_parseUrl url
|
|
108
|
+
async = true if async is undefined
|
|
109
|
+
|
|
110
|
+
switch @readyState
|
|
111
|
+
when XMLHttpRequest.UNSENT, XMLHttpRequest.OPENED, XMLHttpRequest.DONE
|
|
112
|
+
# Nothing to do here.
|
|
113
|
+
null
|
|
114
|
+
when XMLHttpRequest.HEADERS_RECEIVED, XMLHttpRequest.LOADING
|
|
115
|
+
# TODO(pwnall): terminate abort(), terminate send()
|
|
116
|
+
null
|
|
117
|
+
|
|
118
|
+
@_method = method
|
|
119
|
+
@_url = xhrUrl
|
|
120
|
+
@_sync = !async
|
|
121
|
+
@_headers = {}
|
|
122
|
+
@_loweredHeaders = {}
|
|
123
|
+
@_mimeOverride = null
|
|
124
|
+
@_setReadyState XMLHttpRequest.OPENED
|
|
125
|
+
@_request = null
|
|
126
|
+
@_response = null
|
|
127
|
+
@status = 0
|
|
128
|
+
@statusText = ''
|
|
129
|
+
@_responseParts = []
|
|
130
|
+
@_responseHeaders = null
|
|
131
|
+
@_loadedBytes = 0
|
|
132
|
+
@_totalBytes = 0
|
|
133
|
+
@_lengthComputable = false
|
|
134
|
+
undefined
|
|
135
|
+
|
|
136
|
+
# Appends a header to the list of author request headers.
|
|
137
|
+
#
|
|
138
|
+
# @param {String} name the HTTP header name
|
|
139
|
+
# @param {String} value the HTTP header value
|
|
140
|
+
# @return {undefined} undefined
|
|
141
|
+
# @throw {InvalidStateError} readyState is not OPENED
|
|
142
|
+
# @throw {SyntaxError} name is not a valid HTTP header name or value is not
|
|
143
|
+
# a valid HTTP header value
|
|
144
|
+
# @see http://www.w3.org/TR/XMLHttpRequest/#the-setrequestheader()-method
|
|
145
|
+
setRequestHeader: (name, value) ->
|
|
146
|
+
unless @readyState is XMLHttpRequest.OPENED
|
|
147
|
+
throw new InvalidStateError "XHR readyState must be OPENED"
|
|
148
|
+
|
|
149
|
+
loweredName = name.toLowerCase()
|
|
150
|
+
if @_restrictedHeaders[loweredName] or /^sec\-/.test(loweredName) or
|
|
151
|
+
/^proxy-/.test(loweredName)
|
|
152
|
+
console.warn "Refused to set unsafe header \"#{name}\""
|
|
153
|
+
return undefined
|
|
154
|
+
|
|
155
|
+
value = value.toString()
|
|
156
|
+
if loweredName of @_loweredHeaders
|
|
157
|
+
# Combine value with the existing header value.
|
|
158
|
+
name = @_loweredHeaders[loweredName]
|
|
159
|
+
@_headers[name] = @_headers[name] + ', ' + value
|
|
160
|
+
else
|
|
161
|
+
# New header.
|
|
162
|
+
@_loweredHeaders[loweredName] = name
|
|
163
|
+
@_headers[name] = value
|
|
164
|
+
|
|
165
|
+
undefined
|
|
166
|
+
|
|
167
|
+
# Initiates the request.
|
|
168
|
+
#
|
|
169
|
+
# @param {?String, ?ArrayBufferView} data the data to be sent; ignored for
|
|
170
|
+
# GET and HEAD requests
|
|
171
|
+
# @return {undefined} undefined
|
|
172
|
+
# @throw {InvalidStateError} readyState is not OPENED
|
|
173
|
+
# @see http://www.w3.org/TR/XMLHttpRequest/#the-send()-method
|
|
174
|
+
send: (data) ->
|
|
175
|
+
unless @readyState is XMLHttpRequest.OPENED
|
|
176
|
+
throw new InvalidStateError "XHR readyState must be OPENED"
|
|
177
|
+
|
|
178
|
+
if @_request
|
|
179
|
+
throw new InvalidStateError "send() already called"
|
|
180
|
+
|
|
181
|
+
switch @_url.protocol
|
|
182
|
+
when 'file:'
|
|
183
|
+
@_sendFile data
|
|
184
|
+
when 'http:', 'https:'
|
|
185
|
+
@_sendHttp data
|
|
186
|
+
else
|
|
187
|
+
throw new NetworkError "Unsupported protocol #{@_url.protocol}"
|
|
188
|
+
|
|
189
|
+
undefined
|
|
190
|
+
|
|
191
|
+
# Cancels the network activity performed by this request.
|
|
192
|
+
#
|
|
193
|
+
# @return {undefined} undefined
|
|
194
|
+
# @see http://www.w3.org/TR/XMLHttpRequest/#the-abort()-method
|
|
195
|
+
abort: ->
|
|
196
|
+
return unless @_request
|
|
197
|
+
|
|
198
|
+
@_request.abort()
|
|
199
|
+
@_setError()
|
|
200
|
+
@_dispatchProgress 'abort'
|
|
201
|
+
@_dispatchProgress 'loadend'
|
|
202
|
+
undefined
|
|
203
|
+
|
|
204
|
+
# Returns a header value in the HTTP response for this XHR.
|
|
205
|
+
#
|
|
206
|
+
# @param {String} name case-insensitive HTTP header name
|
|
207
|
+
# @return {?String} value the value of the header whose name matches the
|
|
208
|
+
# given name, or null if there is no such header
|
|
209
|
+
# @see http://www.w3.org/TR/XMLHttpRequest/#the-getresponseheader()-method
|
|
210
|
+
getResponseHeader: (name) ->
|
|
211
|
+
return null unless @_responseHeaders
|
|
212
|
+
|
|
213
|
+
loweredName = name.toLowerCase()
|
|
214
|
+
if loweredName of @_responseHeaders
|
|
215
|
+
@_responseHeaders[loweredName]
|
|
216
|
+
else
|
|
217
|
+
null
|
|
218
|
+
|
|
219
|
+
# Returns all the HTTP headers in this XHR's response.
|
|
220
|
+
#
|
|
221
|
+
# @return {String} header lines separated by CR LF, where each header line
|
|
222
|
+
# has the name and value separated by a ": " (colon, space); the empty
|
|
223
|
+
# string is returned if the headers are not available
|
|
224
|
+
# @see http://www.w3.org/TR/XMLHttpRequest/#the-getallresponseheaders()-method
|
|
225
|
+
getAllResponseHeaders: ->
|
|
226
|
+
return '' unless @_responseHeaders
|
|
227
|
+
|
|
228
|
+
lines = ("#{name}: #{value}" for name, value of @_responseHeaders)
|
|
229
|
+
lines.join "\r\n"
|
|
230
|
+
|
|
231
|
+
# Overrides the Content-Type
|
|
232
|
+
#
|
|
233
|
+
# @return {undefined} undefined
|
|
234
|
+
# @see http://www.w3.org/TR/XMLHttpRequest/#the-overridemimetype()-method
|
|
235
|
+
overrideMimeType: (newMimeType) ->
|
|
236
|
+
if @readyState is XMLHttpRequest.LOADING or
|
|
237
|
+
@readyState is XMLHttpRequest.DONE
|
|
238
|
+
throw new InvalidStateError(
|
|
239
|
+
"overrideMimeType() not allowed in LOADING or DONE")
|
|
240
|
+
|
|
241
|
+
@_mimeOverride = newMimeType.toLowerCase()
|
|
242
|
+
undefined
|
|
243
|
+
|
|
244
|
+
# Network configuration not exposed in the XHR API.
|
|
245
|
+
#
|
|
246
|
+
# Although the XMLHttpRequest specification calls itself "ECMAScript HTTP",
|
|
247
|
+
# it assumes that requests are always performed in the context of a browser
|
|
248
|
+
# application, where some network parameters are set by the browser user and
|
|
249
|
+
# should not be modified by Web applications. This API provides access to
|
|
250
|
+
# these network parameters.
|
|
251
|
+
#
|
|
252
|
+
# NOTE: this is not in the XMLHttpRequest API, and will not work in
|
|
253
|
+
# browsers. It is a stable node-xhr2 API.
|
|
254
|
+
#
|
|
255
|
+
# @param {Object} options one or more of the options below
|
|
256
|
+
# @option options {?http.Agent} httpAgent the value for the nodejsHttpAgent
|
|
257
|
+
# property (the agent used for HTTP requests)
|
|
258
|
+
# @option options {?https.Agent} httpsAgent the value for the
|
|
259
|
+
# nodejsHttpsAgent property (the agent used for HTTPS requests)
|
|
260
|
+
# @return {undefined} undefined
|
|
261
|
+
nodejsSet: (options) ->
|
|
262
|
+
if 'httpAgent' of options
|
|
263
|
+
@nodejsHttpAgent = options.httpAgent
|
|
264
|
+
if 'httpsAgent' of options
|
|
265
|
+
@nodejsHttpsAgent = options.httpsAgent
|
|
266
|
+
if 'baseUrl' of options
|
|
267
|
+
baseUrl = options.baseUrl
|
|
268
|
+
unless baseUrl is null
|
|
269
|
+
parsedUrl = url.parse baseUrl, false, true
|
|
270
|
+
unless parsedUrl.protocol
|
|
271
|
+
throw new SyntaxError("baseUrl must be an absolute URL")
|
|
272
|
+
@nodejsBaseUrl = baseUrl
|
|
273
|
+
|
|
274
|
+
undefined
|
|
275
|
+
|
|
276
|
+
# Default settings for the network configuration not exposed in the XHR API.
|
|
277
|
+
#
|
|
278
|
+
# NOTE: this is not in the XMLHttpRequest API, and will not work in
|
|
279
|
+
# browsers. It is a stable node-xhr2 API.
|
|
280
|
+
#
|
|
281
|
+
# @param {Object} options one or more of the options below
|
|
282
|
+
# @option options {?http.Agent} httpAgent the default value for the
|
|
283
|
+
# nodejsHttpAgent property (the agent used for HTTP requests)
|
|
284
|
+
# @option options {https.Agent} httpsAgent the default value for the
|
|
285
|
+
# nodejsHttpsAgent property (the agent used for HTTPS requests)
|
|
286
|
+
# @return {undefined} undefined
|
|
287
|
+
# @see XMLHttpRequest.nodejsSet
|
|
288
|
+
@nodejsSet: (options) ->
|
|
289
|
+
# "this" will be set to XMLHttpRequest.prototype, so the instance nodejsSet
|
|
290
|
+
# operates on default property values.
|
|
291
|
+
XMLHttpRequest::nodejsSet options
|
|
292
|
+
|
|
293
|
+
undefined
|
|
294
|
+
|
|
295
|
+
# readyState value before XMLHttpRequest#open() is called
|
|
296
|
+
UNSENT: 0
|
|
297
|
+
# readyState value before XMLHttpRequest#open() is called
|
|
298
|
+
@UNSENT: 0
|
|
299
|
+
|
|
300
|
+
# readyState value after XMLHttpRequest#open() is called, and before
|
|
301
|
+
# XMLHttpRequest#send() is called; XMLHttpRequest#setRequestHeader() can be
|
|
302
|
+
# called in this state
|
|
303
|
+
OPENED: 1
|
|
304
|
+
# readyState value after XMLHttpRequest#open() is called, and before
|
|
305
|
+
# XMLHttpRequest#send() is called; XMLHttpRequest#setRequestHeader() can be
|
|
306
|
+
# called in this state
|
|
307
|
+
@OPENED: 1
|
|
308
|
+
|
|
309
|
+
# readyState value after redirects have been followed and the HTTP headers of
|
|
310
|
+
# the final response have been received
|
|
311
|
+
HEADERS_RECEIVED: 2
|
|
312
|
+
# readyState value after redirects have been followed and the HTTP headers of
|
|
313
|
+
# the final response have been received
|
|
314
|
+
@HEADERS_RECEIVED: 2
|
|
315
|
+
|
|
316
|
+
# readyState value when the response entity body is being received
|
|
317
|
+
LOADING: 3
|
|
318
|
+
# readyState value when the response entity body is being received
|
|
319
|
+
@LOADING: 3
|
|
320
|
+
|
|
321
|
+
# readyState value after the request has been completely processed
|
|
322
|
+
DONE: 4
|
|
323
|
+
# readyState value after the request has been completely processed
|
|
324
|
+
@DONE: 4
|
|
325
|
+
|
|
326
|
+
# @property {http.Agent} the agent option passed to HTTP requests
|
|
327
|
+
#
|
|
328
|
+
# NOTE: this is not in the XMLHttpRequest API, and will not work in browsers.
|
|
329
|
+
# It is a stable node-xhr2 API that is useful for testing & going through
|
|
330
|
+
# web-proxies.
|
|
331
|
+
nodejsHttpAgent: http.globalAgent
|
|
332
|
+
|
|
333
|
+
# @property {https.Agent} the agent option passed to HTTPS requests
|
|
334
|
+
#
|
|
335
|
+
# NOTE: this is not in the XMLHttpRequest API, and will not work in browsers.
|
|
336
|
+
# It is a stable node-xhr2 API that is useful for testing & going through
|
|
337
|
+
# web-proxies.
|
|
338
|
+
nodejsHttpsAgent: https.globalAgent
|
|
339
|
+
|
|
340
|
+
# @property {String} the base URL that relative URLs get resolved to
|
|
341
|
+
#
|
|
342
|
+
# NOTE: this is not in the XMLHttpRequest API, and will not work in browsers.
|
|
343
|
+
# Its browser equivalent is the base URL of the document associated with the
|
|
344
|
+
# Window object. It is a stable node-xhr2 API provided for libraries such as
|
|
345
|
+
# Angular Universal.
|
|
346
|
+
nodejsBaseUrl: null
|
|
347
|
+
|
|
348
|
+
# HTTP methods that are disallowed in the XHR spec.
|
|
349
|
+
#
|
|
350
|
+
# @private
|
|
351
|
+
# @see Step 6 in http://www.w3.org/TR/XMLHttpRequest/#the-open()-method
|
|
352
|
+
_restrictedMethods:
|
|
353
|
+
CONNECT: true
|
|
354
|
+
TRACE: true
|
|
355
|
+
TRACK: true
|
|
356
|
+
|
|
357
|
+
# HTTP request headers that are disallowed in the XHR spec.
|
|
358
|
+
#
|
|
359
|
+
# @private
|
|
360
|
+
# @see Step 5 in
|
|
361
|
+
# http://www.w3.org/TR/XMLHttpRequest/#the-setrequestheader()-method
|
|
362
|
+
_restrictedHeaders:
|
|
363
|
+
'accept-charset': true
|
|
364
|
+
'accept-encoding': true
|
|
365
|
+
'access-control-request-headers': true
|
|
366
|
+
'access-control-request-method': true
|
|
367
|
+
connection: true
|
|
368
|
+
'content-length': true
|
|
369
|
+
cookie: true
|
|
370
|
+
cookie2: true
|
|
371
|
+
date: true
|
|
372
|
+
dnt: true
|
|
373
|
+
expect: true
|
|
374
|
+
host: true
|
|
375
|
+
'keep-alive': true
|
|
376
|
+
origin: true
|
|
377
|
+
referer: true
|
|
378
|
+
te: true
|
|
379
|
+
trailer: true
|
|
380
|
+
'transfer-encoding': true
|
|
381
|
+
upgrade: true
|
|
382
|
+
'user-agent': true
|
|
383
|
+
via: true
|
|
384
|
+
|
|
385
|
+
# HTTP response headers that should not be exposed according to the XHR spec.
|
|
386
|
+
#
|
|
387
|
+
# @private
|
|
388
|
+
# @see Step 3 in
|
|
389
|
+
# http://www.w3.org/TR/XMLHttpRequest/#the-getresponseheader()-method
|
|
390
|
+
_privateHeaders:
|
|
391
|
+
'set-cookie': true
|
|
392
|
+
'set-cookie2': true
|
|
393
|
+
|
|
394
|
+
# The value of the User-Agent header.
|
|
395
|
+
_userAgent: "Mozilla/5.0 (#{os.type()} #{os.arch()}) " +
|
|
396
|
+
"node.js/#{process.versions.node} v8/#{process.versions.v8}"
|
|
397
|
+
|
|
398
|
+
# Sets the readyState property and fires the readystatechange event.
|
|
399
|
+
#
|
|
400
|
+
# @private
|
|
401
|
+
# @param {Number} newReadyState the new value of readyState
|
|
402
|
+
# @return {undefined} undefined
|
|
403
|
+
_setReadyState: (newReadyState) ->
|
|
404
|
+
@readyState = newReadyState
|
|
405
|
+
event = new ProgressEvent 'readystatechange'
|
|
406
|
+
@dispatchEvent event
|
|
407
|
+
undefined
|
|
408
|
+
|
|
409
|
+
# XMLHttpRequest#send() implementation for the file: protocol.
|
|
410
|
+
#
|
|
411
|
+
# @private
|
|
412
|
+
_sendFile: ->
|
|
413
|
+
unless @_url.method is 'GET'
|
|
414
|
+
throw new NetworkError 'The file protocol only supports GET'
|
|
415
|
+
|
|
416
|
+
throw new Error "Protocol file: not implemented"
|
|
417
|
+
|
|
418
|
+
# XMLHttpRequest#send() implementation for the http: and https: protocols.
|
|
419
|
+
#
|
|
420
|
+
# @private
|
|
421
|
+
# This method sets the instance variables and calls _sendHxxpRequest(), which
|
|
422
|
+
# is responsible for building a node.js request and firing it off. The code
|
|
423
|
+
# in _sendHxxpRequest() is separated off so it can be reused when handling
|
|
424
|
+
# redirects.
|
|
425
|
+
#
|
|
426
|
+
# @see http://www.w3.org/TR/XMLHttpRequest/#infrastructure-for-the-send()-method
|
|
427
|
+
_sendHttp: (data) ->
|
|
428
|
+
if @_sync
|
|
429
|
+
throw new Error "Synchronous XHR processing not implemented"
|
|
430
|
+
|
|
431
|
+
if data? and (@_method is 'GET' or @_method is 'HEAD')
|
|
432
|
+
console.warn "Discarding entity body for #{@_method} requests"
|
|
433
|
+
data = null
|
|
434
|
+
else
|
|
435
|
+
# Send Content-Length: 0
|
|
436
|
+
data or= ''
|
|
437
|
+
|
|
438
|
+
# NOTE: this is called before finalizeHeaders so that the uploader can
|
|
439
|
+
# figure out Content-Length and Content-Type.
|
|
440
|
+
@upload._setData data
|
|
441
|
+
@_finalizeHeaders()
|
|
442
|
+
|
|
443
|
+
@_sendHxxpRequest()
|
|
444
|
+
undefined
|
|
445
|
+
|
|
446
|
+
# Sets up and fires off a HTTP/HTTPS request using the node.js API.
|
|
447
|
+
#
|
|
448
|
+
# @private
|
|
449
|
+
# This method contains the bulk of the XMLHttpRequest#send() implementation,
|
|
450
|
+
# and is also used to issue new HTTP requests when handling HTTP redirects.
|
|
451
|
+
#
|
|
452
|
+
# @see http://www.w3.org/TR/XMLHttpRequest/#infrastructure-for-the-send()-method
|
|
453
|
+
_sendHxxpRequest: ->
|
|
454
|
+
if @_url.protocol is 'http:'
|
|
455
|
+
hxxp = http
|
|
456
|
+
agent = @nodejsHttpAgent
|
|
457
|
+
else
|
|
458
|
+
hxxp = https
|
|
459
|
+
agent = @nodejsHttpsAgent
|
|
460
|
+
|
|
461
|
+
request = hxxp.request
|
|
462
|
+
hostname: @_url.hostname, port: @_url.port, path: @_url.path,
|
|
463
|
+
auth: @_url.auth, method: @_method, headers: @_headers, agent: agent
|
|
464
|
+
@_request = request
|
|
465
|
+
if @timeout
|
|
466
|
+
request.setTimeout @timeout, => @_onHttpTimeout request
|
|
467
|
+
request.on 'response', (response) => @_onHttpResponse request, response
|
|
468
|
+
request.on 'error', (error) => @_onHttpRequestError request, error
|
|
469
|
+
@upload._startUpload request
|
|
470
|
+
if @_request is request # An http error might have already fired.
|
|
471
|
+
@_dispatchProgress 'loadstart'
|
|
472
|
+
|
|
473
|
+
undefined
|
|
474
|
+
|
|
475
|
+
# Fills in the restricted HTTP headers with default values.
|
|
476
|
+
#
|
|
477
|
+
# This is called right before the HTTP request is sent off.
|
|
478
|
+
#
|
|
479
|
+
# @private
|
|
480
|
+
# @return {undefined} undefined
|
|
481
|
+
_finalizeHeaders: ->
|
|
482
|
+
@_headers['Connection'] = 'keep-alive'
|
|
483
|
+
@_headers['Host'] = @_url.host
|
|
484
|
+
if @_anonymous
|
|
485
|
+
@_headers['Referer'] = 'about:blank'
|
|
486
|
+
@_headers['User-Agent'] = @_userAgent
|
|
487
|
+
@upload._finalizeHeaders @_headers, @_loweredHeaders
|
|
488
|
+
undefined
|
|
489
|
+
|
|
490
|
+
|
|
491
|
+
# Called when the headers of an HTTP response have been received.
|
|
492
|
+
#
|
|
493
|
+
# @private
|
|
494
|
+
# @param {http.ClientRequest} request the node.js ClientRequest instance that
|
|
495
|
+
# produced this response
|
|
496
|
+
# @param {http.ClientResponse} response the node.js ClientResponse instance
|
|
497
|
+
# passed to
|
|
498
|
+
_onHttpResponse: (request, response) ->
|
|
499
|
+
return unless @_request is request
|
|
500
|
+
|
|
501
|
+
# Transparent redirection handling.
|
|
502
|
+
switch response.statusCode
|
|
503
|
+
when 301, 302, 303, 307, 308
|
|
504
|
+
@_url = @_parseUrl response.headers['location']
|
|
505
|
+
@_method = 'GET'
|
|
506
|
+
if 'content-type' of @_loweredHeaders
|
|
507
|
+
delete @_headers[@_loweredHeaders['content-type']]
|
|
508
|
+
delete @_loweredHeaders['content-type']
|
|
509
|
+
# XMLHttpRequestUpload#_finalizeHeaders() sets Content-Type directly.
|
|
510
|
+
if 'Content-Type' of @_headers
|
|
511
|
+
delete @_headers['Content-Type']
|
|
512
|
+
# Restricted headers can't be set by the user, no need to check
|
|
513
|
+
# loweredHeaders.
|
|
514
|
+
delete @_headers['Content-Length']
|
|
515
|
+
|
|
516
|
+
@upload._reset()
|
|
517
|
+
@_finalizeHeaders()
|
|
518
|
+
@_sendHxxpRequest()
|
|
519
|
+
return
|
|
520
|
+
|
|
521
|
+
@_response = response
|
|
522
|
+
@_response.on 'data', (data) => @_onHttpResponseData response, data
|
|
523
|
+
@_response.on 'end', => @_onHttpResponseEnd response
|
|
524
|
+
@_response.on 'close', => @_onHttpResponseClose response
|
|
525
|
+
|
|
526
|
+
@responseURL = @_url.href.split('#')[0]
|
|
527
|
+
@status = @_response.statusCode
|
|
528
|
+
@statusText = http.STATUS_CODES[@status]
|
|
529
|
+
@_parseResponseHeaders response
|
|
530
|
+
|
|
531
|
+
if lengthString = @_responseHeaders['content-length']
|
|
532
|
+
@_totalBytes = parseInt(lengthString)
|
|
533
|
+
@_lengthComputable = true
|
|
534
|
+
else
|
|
535
|
+
@_lengthComputable = false
|
|
536
|
+
|
|
537
|
+
@_setReadyState XMLHttpRequest.HEADERS_RECEIVED
|
|
538
|
+
|
|
539
|
+
# Called when some data has been received on a HTTP connection.
|
|
540
|
+
#
|
|
541
|
+
# @private
|
|
542
|
+
# @param {http.ClientResponse} response the node.js ClientResponse instance
|
|
543
|
+
# that fired this event
|
|
544
|
+
# @param {String, Buffer} data the data that has been received
|
|
545
|
+
_onHttpResponseData: (response, data) ->
|
|
546
|
+
return unless @_response is response
|
|
547
|
+
|
|
548
|
+
@_responseParts.push data
|
|
549
|
+
@_loadedBytes += data.length
|
|
550
|
+
|
|
551
|
+
if @readyState isnt XMLHttpRequest.LOADING
|
|
552
|
+
@_setReadyState XMLHttpRequest.LOADING
|
|
553
|
+
@_dispatchProgress 'progress'
|
|
554
|
+
|
|
555
|
+
# Called when the HTTP request finished processing.
|
|
556
|
+
#
|
|
557
|
+
# @private
|
|
558
|
+
# @param {http.ClientResponse} response the node.js ClientResponse instance
|
|
559
|
+
# that fired this event
|
|
560
|
+
_onHttpResponseEnd: (response) ->
|
|
561
|
+
return unless @_response is response
|
|
562
|
+
|
|
563
|
+
@_parseResponse()
|
|
564
|
+
|
|
565
|
+
@_request = null
|
|
566
|
+
@_response = null
|
|
567
|
+
@_setReadyState XMLHttpRequest.DONE
|
|
568
|
+
@_dispatchProgress 'load'
|
|
569
|
+
@_dispatchProgress 'loadend'
|
|
570
|
+
|
|
571
|
+
# Called when the underlying HTTP connection was closed prematurely.
|
|
572
|
+
#
|
|
573
|
+
# If this method is called, it will be called after or instead of
|
|
574
|
+
# onHttpResponseEnd.
|
|
575
|
+
#
|
|
576
|
+
# @private
|
|
577
|
+
# @param {http.ClientResponse} response the node.js ClientResponse instance
|
|
578
|
+
# that fired this event
|
|
579
|
+
_onHttpResponseClose: (response) ->
|
|
580
|
+
return unless @_response is response
|
|
581
|
+
|
|
582
|
+
request = @_request
|
|
583
|
+
@_setError()
|
|
584
|
+
request.abort()
|
|
585
|
+
@_setReadyState XMLHttpRequest.DONE
|
|
586
|
+
@_dispatchProgress 'error'
|
|
587
|
+
@_dispatchProgress 'loadend'
|
|
588
|
+
|
|
589
|
+
# Called when the timeout set on the HTTP socket expires.
|
|
590
|
+
#
|
|
591
|
+
# @private
|
|
592
|
+
# @param {http.ClientRequest} request the node.js ClientRequest instance that
|
|
593
|
+
# fired this event
|
|
594
|
+
_onHttpTimeout: (request) ->
|
|
595
|
+
return unless @_request is request
|
|
596
|
+
|
|
597
|
+
@_setError()
|
|
598
|
+
request.abort()
|
|
599
|
+
@_setReadyState XMLHttpRequest.DONE
|
|
600
|
+
@_dispatchProgress 'timeout'
|
|
601
|
+
@_dispatchProgress 'loadend'
|
|
602
|
+
|
|
603
|
+
# Called when something wrong happens on the HTTP socket
|
|
604
|
+
#
|
|
605
|
+
# @private
|
|
606
|
+
# @param {http.ClientRequest} request the node.js ClientRequest instance that
|
|
607
|
+
# fired this event
|
|
608
|
+
# @param {Error} error emitted exception
|
|
609
|
+
_onHttpRequestError: (request, error) ->
|
|
610
|
+
return unless @_request is request
|
|
611
|
+
|
|
612
|
+
@_setError()
|
|
613
|
+
request.abort()
|
|
614
|
+
@_setReadyState XMLHttpRequest.DONE
|
|
615
|
+
@_dispatchProgress 'error'
|
|
616
|
+
@_dispatchProgress 'loadend'
|
|
617
|
+
|
|
618
|
+
# Fires an XHR progress event.
|
|
619
|
+
#
|
|
620
|
+
# @private
|
|
621
|
+
# @param {String} eventType one of the XHR progress event types, such as
|
|
622
|
+
# 'load' and 'progress'
|
|
623
|
+
_dispatchProgress: (eventType) ->
|
|
624
|
+
event = new ProgressEvent eventType
|
|
625
|
+
event.lengthComputable = @_lengthComputable
|
|
626
|
+
event.loaded = @_loadedBytes
|
|
627
|
+
event.total = @_totalBytes
|
|
628
|
+
@dispatchEvent event
|
|
629
|
+
undefined
|
|
630
|
+
|
|
631
|
+
# Sets up the XHR to reflect the fact that an error has occurred.
|
|
632
|
+
#
|
|
633
|
+
# The possible errors are a network error, a timeout, or an abort.
|
|
634
|
+
#
|
|
635
|
+
# @private
|
|
636
|
+
_setError: ->
|
|
637
|
+
@_request = null
|
|
638
|
+
@_response = null
|
|
639
|
+
@_responseHeaders = null
|
|
640
|
+
@_responseParts = null
|
|
641
|
+
undefined
|
|
642
|
+
|
|
643
|
+
# Parses a request URL string.
|
|
644
|
+
#
|
|
645
|
+
# @private
|
|
646
|
+
# This method is a thin wrapper around url.parse() that normalizes HTTP
|
|
647
|
+
# user/password credentials. It is used to parse the URL string passed to
|
|
648
|
+
# XMLHttpRequest#open() and the URLs in the Location headers of HTTP redirect
|
|
649
|
+
# responses.
|
|
650
|
+
#
|
|
651
|
+
# @param {String} urlString the URL to be parsed
|
|
652
|
+
# @return {Object} parsed URL
|
|
653
|
+
_parseUrl: (urlString) ->
|
|
654
|
+
if @nodejsBaseUrl is null
|
|
655
|
+
absoluteUrlString = urlString
|
|
656
|
+
else
|
|
657
|
+
absoluteUrlString = url.resolve @nodejsBaseUrl, urlString
|
|
658
|
+
|
|
659
|
+
xhrUrl = url.parse absoluteUrlString, false, true
|
|
660
|
+
xhrUrl.hash = null
|
|
661
|
+
if xhrUrl.auth and (user? or password?)
|
|
662
|
+
index = xhrUrl.auth.indexOf ':'
|
|
663
|
+
if index is -1
|
|
664
|
+
user = xhrUrl.auth unless user
|
|
665
|
+
else
|
|
666
|
+
user = xhrUrl.substring(0, index) unless user
|
|
667
|
+
password = xhrUrl.substring(index + 1) unless password
|
|
668
|
+
if user or password
|
|
669
|
+
xhrUrl.auth = "#{user}:#{password}"
|
|
670
|
+
xhrUrl
|
|
671
|
+
|
|
672
|
+
# Reads the headers from a node.js ClientResponse instance.
|
|
673
|
+
#
|
|
674
|
+
# @private
|
|
675
|
+
# @param {http.ClientResponse} response the response whose headers will be
|
|
676
|
+
# imported into this XMLHttpRequest's state
|
|
677
|
+
# @return {undefined} undefined
|
|
678
|
+
# @see http://www.w3.org/TR/XMLHttpRequest/#the-getresponseheader()-method
|
|
679
|
+
# @see http://www.w3.org/TR/XMLHttpRequest/#the-getallresponseheaders()-method
|
|
680
|
+
_parseResponseHeaders: (response) ->
|
|
681
|
+
@_responseHeaders = {}
|
|
682
|
+
for name, value of response.headers
|
|
683
|
+
loweredName = name.toLowerCase()
|
|
684
|
+
continue if @_privateHeaders[loweredName]
|
|
685
|
+
if @_mimeOverride isnt null and loweredName is 'content-type'
|
|
686
|
+
value = @_mimeOverride
|
|
687
|
+
@_responseHeaders[loweredName] = value
|
|
688
|
+
|
|
689
|
+
if @_mimeOverride isnt null and !('content-type' of @_responseHeaders)
|
|
690
|
+
@_responseHeaders['content-type'] = @_mimeOverride
|
|
691
|
+
undefined
|
|
692
|
+
|
|
693
|
+
# Sets the response and responseText properties when an XHR completes.
|
|
694
|
+
#
|
|
695
|
+
# @private
|
|
696
|
+
# @return {undefined} undefined
|
|
697
|
+
_parseResponse: ->
|
|
698
|
+
if Buffer.concat
|
|
699
|
+
buffer = Buffer.concat @_responseParts
|
|
700
|
+
else
|
|
701
|
+
# node 0.6
|
|
702
|
+
buffer = @_concatBuffers @_responseParts
|
|
703
|
+
@_responseParts = null
|
|
704
|
+
|
|
705
|
+
switch @responseType
|
|
706
|
+
when 'text'
|
|
707
|
+
@_parseTextResponse buffer
|
|
708
|
+
when 'json'
|
|
709
|
+
@responseText = null
|
|
710
|
+
try
|
|
711
|
+
@response = JSON.parse buffer.toString('utf-8')
|
|
712
|
+
catch jsonError
|
|
713
|
+
@response = null
|
|
714
|
+
when 'buffer'
|
|
715
|
+
@responseText = null
|
|
716
|
+
@response = buffer
|
|
717
|
+
when 'arraybuffer'
|
|
718
|
+
@responseText = null
|
|
719
|
+
arrayBuffer = new ArrayBuffer buffer.length
|
|
720
|
+
view = new Uint8Array arrayBuffer
|
|
721
|
+
view[i] = buffer[i] for i in [0...buffer.length]
|
|
722
|
+
@response = arrayBuffer
|
|
723
|
+
else
|
|
724
|
+
# TODO(pwnall): content-base detection
|
|
725
|
+
@_parseTextResponse buffer
|
|
726
|
+
undefined
|
|
727
|
+
|
|
728
|
+
# Sets response and responseText for a 'text' response type.
|
|
729
|
+
#
|
|
730
|
+
# @private
|
|
731
|
+
# @param {Buffer} buffer the node.js Buffer containing the binary response
|
|
732
|
+
# @return {undefined} undefined
|
|
733
|
+
_parseTextResponse: (buffer) ->
|
|
734
|
+
try
|
|
735
|
+
@responseText = buffer.toString @_parseResponseEncoding()
|
|
736
|
+
catch e
|
|
737
|
+
# Unknown encoding.
|
|
738
|
+
@responseText = buffer.toString 'binary'
|
|
739
|
+
|
|
740
|
+
@response = @responseText
|
|
741
|
+
undefined
|
|
742
|
+
|
|
743
|
+
# Figures out the string encoding of the XHR's response.
|
|
744
|
+
#
|
|
745
|
+
# This is called to determine the encoding when responseText is set.
|
|
746
|
+
#
|
|
747
|
+
# @private
|
|
748
|
+
# @return {String} a string encoding, e.g. 'utf-8'
|
|
749
|
+
_parseResponseEncoding: ->
|
|
750
|
+
encoding = null
|
|
751
|
+
if contentType = @_responseHeaders['content-type']
|
|
752
|
+
if match = /\;\s*charset\=(.*)$/.exec contentType
|
|
753
|
+
return match[1]
|
|
754
|
+
'utf-8'
|
|
755
|
+
|
|
756
|
+
# Buffer.concat implementation for node 0.6.
|
|
757
|
+
#
|
|
758
|
+
# @private
|
|
759
|
+
# @param {Array<Buffer>} buffers the buffers whose contents will be merged
|
|
760
|
+
# @return {Buffer} same as Buffer.concat(buffers) in node 0.8 and above
|
|
761
|
+
_concatBuffers: (buffers) ->
|
|
762
|
+
if buffers.length is 0
|
|
763
|
+
return Buffer.alloc 0
|
|
764
|
+
if buffers.length is 1
|
|
765
|
+
return buffers[0]
|
|
766
|
+
|
|
767
|
+
length = 0
|
|
768
|
+
length += buffer.length for buffer in buffers
|
|
769
|
+
target = Buffer.alloc length
|
|
770
|
+
length = 0
|
|
771
|
+
for buffer in buffers
|
|
772
|
+
buffer.copy target, length
|
|
773
|
+
length += buffer.length
|
|
774
|
+
target
|
|
775
|
+
|
|
776
|
+
# XMLHttpRequest is the result of require('node-xhr2').
|
|
777
|
+
module.exports = XMLHttpRequest
|
|
778
|
+
|
|
779
|
+
# Make node-xhr2 work as a drop-in replacement for libraries that promote the
|
|
780
|
+
# following usage pattern:
|
|
781
|
+
# var XMLHttpRequest = require('xhr-library-name').XMLHttpRequest
|
|
782
|
+
XMLHttpRequest.XMLHttpRequest = XMLHttpRequest
|