You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sh...@apache.org on 2017/02/22 19:22:20 UTC
[12/27] cordova-plugins git commit: Removed plugins other than
keyboard moved plugin to root
http://git-wip-us.apache.org/repos/asf/cordova-plugins/blob/5d951c9e/local-webserver/src/ios/GCDWebServer/GCDWebUploader/GCDWebUploader.bundle/js/jquery.ui.widget.js
----------------------------------------------------------------------
diff --git a/local-webserver/src/ios/GCDWebServer/GCDWebUploader/GCDWebUploader.bundle/js/jquery.ui.widget.js b/local-webserver/src/ios/GCDWebServer/GCDWebUploader/GCDWebUploader.bundle/js/jquery.ui.widget.js
deleted file mode 100644
index 1c0cbd1..0000000
--- a/local-webserver/src/ios/GCDWebServer/GCDWebUploader/GCDWebUploader.bundle/js/jquery.ui.widget.js
+++ /dev/null
@@ -1,521 +0,0 @@
-/*!
- * jQuery UI Widget 1.10.4
- * http://jqueryui.com
- *
- * Copyright 2014 jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- *
- * http://api.jqueryui.com/jQuery.widget/
- */
-(function( $, undefined ) {
-
-var uuid = 0,
- slice = Array.prototype.slice,
- _cleanData = $.cleanData;
-$.cleanData = function( elems ) {
- for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
- try {
- $( elem ).triggerHandler( "remove" );
- // http://bugs.jquery.com/ticket/8235
- } catch( e ) {}
- }
- _cleanData( elems );
-};
-
-$.widget = function( name, base, prototype ) {
- var fullName, existingConstructor, constructor, basePrototype,
- // proxiedPrototype allows the provided prototype to remain unmodified
- // so that it can be used as a mixin for multiple widgets (#8876)
- proxiedPrototype = {},
- namespace = name.split( "." )[ 0 ];
-
- name = name.split( "." )[ 1 ];
- fullName = namespace + "-" + name;
-
- if ( !prototype ) {
- prototype = base;
- base = $.Widget;
- }
-
- // create selector for plugin
- $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) {
- return !!$.data( elem, fullName );
- };
-
- $[ namespace ] = $[ namespace ] || {};
- existingConstructor = $[ namespace ][ name ];
- constructor = $[ namespace ][ name ] = function( options, element ) {
- // allow instantiation without "new" keyword
- if ( !this._createWidget ) {
- return new constructor( options, element );
- }
-
- // allow instantiation without initializing for simple inheritance
- // must use "new" keyword (the code above always passes args)
- if ( arguments.length ) {
- this._createWidget( options, element );
- }
- };
- // extend with the existing constructor to carry over any static properties
- $.extend( constructor, existingConstructor, {
- version: prototype.version,
- // copy the object used to create the prototype in case we need to
- // redefine the widget later
- _proto: $.extend( {}, prototype ),
- // track widgets that inherit from this widget in case this widget is
- // redefined after a widget inherits from it
- _childConstructors: []
- });
-
- basePrototype = new base();
- // we need to make the options hash a property directly on the new instance
- // otherwise we'll modify the options hash on the prototype that we're
- // inheriting from
- basePrototype.options = $.widget.extend( {}, basePrototype.options );
- $.each( prototype, function( prop, value ) {
- if ( !$.isFunction( value ) ) {
- proxiedPrototype[ prop ] = value;
- return;
- }
- proxiedPrototype[ prop ] = (function() {
- var _super = function() {
- return base.prototype[ prop ].apply( this, arguments );
- },
- _superApply = function( args ) {
- return base.prototype[ prop ].apply( this, args );
- };
- return function() {
- var __super = this._super,
- __superApply = this._superApply,
- returnValue;
-
- this._super = _super;
- this._superApply = _superApply;
-
- returnValue = value.apply( this, arguments );
-
- this._super = __super;
- this._superApply = __superApply;
-
- return returnValue;
- };
- })();
- });
- constructor.prototype = $.widget.extend( basePrototype, {
- // TODO: remove support for widgetEventPrefix
- // always use the name + a colon as the prefix, e.g., draggable:start
- // don't prefix for widgets that aren't DOM-based
- widgetEventPrefix: existingConstructor ? (basePrototype.widgetEventPrefix || name) : name
- }, proxiedPrototype, {
- constructor: constructor,
- namespace: namespace,
- widgetName: name,
- widgetFullName: fullName
- });
-
- // If this widget is being redefined then we need to find all widgets that
- // are inheriting from it and redefine all of them so that they inherit from
- // the new version of this widget. We're essentially trying to replace one
- // level in the prototype chain.
- if ( existingConstructor ) {
- $.each( existingConstructor._childConstructors, function( i, child ) {
- var childPrototype = child.prototype;
-
- // redefine the child widget using the same prototype that was
- // originally used, but inherit from the new version of the base
- $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, child._proto );
- });
- // remove the list of existing child constructors from the old constructor
- // so the old child constructors can be garbage collected
- delete existingConstructor._childConstructors;
- } else {
- base._childConstructors.push( constructor );
- }
-
- $.widget.bridge( name, constructor );
-};
-
-$.widget.extend = function( target ) {
- var input = slice.call( arguments, 1 ),
- inputIndex = 0,
- inputLength = input.length,
- key,
- value;
- for ( ; inputIndex < inputLength; inputIndex++ ) {
- for ( key in input[ inputIndex ] ) {
- value = input[ inputIndex ][ key ];
- if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {
- // Clone objects
- if ( $.isPlainObject( value ) ) {
- target[ key ] = $.isPlainObject( target[ key ] ) ?
- $.widget.extend( {}, target[ key ], value ) :
- // Don't extend strings, arrays, etc. with objects
- $.widget.extend( {}, value );
- // Copy everything else by reference
- } else {
- target[ key ] = value;
- }
- }
- }
- }
- return target;
-};
-
-$.widget.bridge = function( name, object ) {
- var fullName = object.prototype.widgetFullName || name;
- $.fn[ name ] = function( options ) {
- var isMethodCall = typeof options === "string",
- args = slice.call( arguments, 1 ),
- returnValue = this;
-
- // allow multiple hashes to be passed on init
- options = !isMethodCall && args.length ?
- $.widget.extend.apply( null, [ options ].concat(args) ) :
- options;
-
- if ( isMethodCall ) {
- this.each(function() {
- var methodValue,
- instance = $.data( this, fullName );
- if ( !instance ) {
- return $.error( "cannot call methods on " + name + " prior to initialization; " +
- "attempted to call method '" + options + "'" );
- }
- if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) {
- return $.error( "no such method '" + options + "' for " + name + " widget instance" );
- }
- methodValue = instance[ options ].apply( instance, args );
- if ( methodValue !== instance && methodValue !== undefined ) {
- returnValue = methodValue && methodValue.jquery ?
- returnValue.pushStack( methodValue.get() ) :
- methodValue;
- return false;
- }
- });
- } else {
- this.each(function() {
- var instance = $.data( this, fullName );
- if ( instance ) {
- instance.option( options || {} )._init();
- } else {
- $.data( this, fullName, new object( options, this ) );
- }
- });
- }
-
- return returnValue;
- };
-};
-
-$.Widget = function( /* options, element */ ) {};
-$.Widget._childConstructors = [];
-
-$.Widget.prototype = {
- widgetName: "widget",
- widgetEventPrefix: "",
- defaultElement: "<div>",
- options: {
- disabled: false,
-
- // callbacks
- create: null
- },
- _createWidget: function( options, element ) {
- element = $( element || this.defaultElement || this )[ 0 ];
- this.element = $( element );
- this.uuid = uuid++;
- this.eventNamespace = "." + this.widgetName + this.uuid;
- this.options = $.widget.extend( {},
- this.options,
- this._getCreateOptions(),
- options );
-
- this.bindings = $();
- this.hoverable = $();
- this.focusable = $();
-
- if ( element !== this ) {
- $.data( element, this.widgetFullName, this );
- this._on( true, this.element, {
- remove: function( event ) {
- if ( event.target === element ) {
- this.destroy();
- }
- }
- });
- this.document = $( element.style ?
- // element within the document
- element.ownerDocument :
- // element is window or document
- element.document || element );
- this.window = $( this.document[0].defaultView || this.document[0].parentWindow );
- }
-
- this._create();
- this._trigger( "create", null, this._getCreateEventData() );
- this._init();
- },
- _getCreateOptions: $.noop,
- _getCreateEventData: $.noop,
- _create: $.noop,
- _init: $.noop,
-
- destroy: function() {
- this._destroy();
- // we can probably remove the unbind calls in 2.0
- // all event bindings should go through this._on()
- this.element
- .unbind( this.eventNamespace )
- // 1.9 BC for #7810
- // TODO remove dual storage
- .removeData( this.widgetName )
- .removeData( this.widgetFullName )
- // support: jquery <1.6.3
- // http://bugs.jquery.com/ticket/9413
- .removeData( $.camelCase( this.widgetFullName ) );
- this.widget()
- .unbind( this.eventNamespace )
- .removeAttr( "aria-disabled" )
- .removeClass(
- this.widgetFullName + "-disabled " +
- "ui-state-disabled" );
-
- // clean up events and states
- this.bindings.unbind( this.eventNamespace );
- this.hoverable.removeClass( "ui-state-hover" );
- this.focusable.removeClass( "ui-state-focus" );
- },
- _destroy: $.noop,
-
- widget: function() {
- return this.element;
- },
-
- option: function( key, value ) {
- var options = key,
- parts,
- curOption,
- i;
-
- if ( arguments.length === 0 ) {
- // don't return a reference to the internal hash
- return $.widget.extend( {}, this.options );
- }
-
- if ( typeof key === "string" ) {
- // handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
- options = {};
- parts = key.split( "." );
- key = parts.shift();
- if ( parts.length ) {
- curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
- for ( i = 0; i < parts.length - 1; i++ ) {
- curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
- curOption = curOption[ parts[ i ] ];
- }
- key = parts.pop();
- if ( arguments.length === 1 ) {
- return curOption[ key ] === undefined ? null : curOption[ key ];
- }
- curOption[ key ] = value;
- } else {
- if ( arguments.length === 1 ) {
- return this.options[ key ] === undefined ? null : this.options[ key ];
- }
- options[ key ] = value;
- }
- }
-
- this._setOptions( options );
-
- return this;
- },
- _setOptions: function( options ) {
- var key;
-
- for ( key in options ) {
- this._setOption( key, options[ key ] );
- }
-
- return this;
- },
- _setOption: function( key, value ) {
- this.options[ key ] = value;
-
- if ( key === "disabled" ) {
- this.widget()
- .toggleClass( this.widgetFullName + "-disabled ui-state-disabled", !!value )
- .attr( "aria-disabled", value );
- this.hoverable.removeClass( "ui-state-hover" );
- this.focusable.removeClass( "ui-state-focus" );
- }
-
- return this;
- },
-
- enable: function() {
- return this._setOption( "disabled", false );
- },
- disable: function() {
- return this._setOption( "disabled", true );
- },
-
- _on: function( suppressDisabledCheck, element, handlers ) {
- var delegateElement,
- instance = this;
-
- // no suppressDisabledCheck flag, shuffle arguments
- if ( typeof suppressDisabledCheck !== "boolean" ) {
- handlers = element;
- element = suppressDisabledCheck;
- suppressDisabledCheck = false;
- }
-
- // no element argument, shuffle and use this.element
- if ( !handlers ) {
- handlers = element;
- element = this.element;
- delegateElement = this.widget();
- } else {
- // accept selectors, DOM elements
- element = delegateElement = $( element );
- this.bindings = this.bindings.add( element );
- }
-
- $.each( handlers, function( event, handler ) {
- function handlerProxy() {
- // allow widgets to customize the disabled handling
- // - disabled as an array instead of boolean
- // - disabled class as method for disabling individual parts
- if ( !suppressDisabledCheck &&
- ( instance.options.disabled === true ||
- $( this ).hasClass( "ui-state-disabled" ) ) ) {
- return;
- }
- return ( typeof handler === "string" ? instance[ handler ] : handler )
- .apply( instance, arguments );
- }
-
- // copy the guid so direct unbinding works
- if ( typeof handler !== "string" ) {
- handlerProxy.guid = handler.guid =
- handler.guid || handlerProxy.guid || $.guid++;
- }
-
- var match = event.match( /^(\w+)\s*(.*)$/ ),
- eventName = match[1] + instance.eventNamespace,
- selector = match[2];
- if ( selector ) {
- delegateElement.delegate( selector, eventName, handlerProxy );
- } else {
- element.bind( eventName, handlerProxy );
- }
- });
- },
-
- _off: function( element, eventName ) {
- eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) + this.eventNamespace;
- element.unbind( eventName ).undelegate( eventName );
- },
-
- _delay: function( handler, delay ) {
- function handlerProxy() {
- return ( typeof handler === "string" ? instance[ handler ] : handler )
- .apply( instance, arguments );
- }
- var instance = this;
- return setTimeout( handlerProxy, delay || 0 );
- },
-
- _hoverable: function( element ) {
- this.hoverable = this.hoverable.add( element );
- this._on( element, {
- mouseenter: function( event ) {
- $( event.currentTarget ).addClass( "ui-state-hover" );
- },
- mouseleave: function( event ) {
- $( event.currentTarget ).removeClass( "ui-state-hover" );
- }
- });
- },
-
- _focusable: function( element ) {
- this.focusable = this.focusable.add( element );
- this._on( element, {
- focusin: function( event ) {
- $( event.currentTarget ).addClass( "ui-state-focus" );
- },
- focusout: function( event ) {
- $( event.currentTarget ).removeClass( "ui-state-focus" );
- }
- });
- },
-
- _trigger: function( type, event, data ) {
- var prop, orig,
- callback = this.options[ type ];
-
- data = data || {};
- event = $.Event( event );
- event.type = ( type === this.widgetEventPrefix ?
- type :
- this.widgetEventPrefix + type ).toLowerCase();
- // the original event may come from any element
- // so we need to reset the target on the new event
- event.target = this.element[ 0 ];
-
- // copy original event properties over to the new event
- orig = event.originalEvent;
- if ( orig ) {
- for ( prop in orig ) {
- if ( !( prop in event ) ) {
- event[ prop ] = orig[ prop ];
- }
- }
- }
-
- this.element.trigger( event, data );
- return !( $.isFunction( callback ) &&
- callback.apply( this.element[0], [ event ].concat( data ) ) === false ||
- event.isDefaultPrevented() );
- }
-};
-
-$.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
- $.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
- if ( typeof options === "string" ) {
- options = { effect: options };
- }
- var hasOptions,
- effectName = !options ?
- method :
- options === true || typeof options === "number" ?
- defaultEffect :
- options.effect || defaultEffect;
- options = options || {};
- if ( typeof options === "number" ) {
- options = { duration: options };
- }
- hasOptions = !$.isEmptyObject( options );
- options.complete = callback;
- if ( options.delay ) {
- element.delay( options.delay );
- }
- if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) {
- element[ method ]( options );
- } else if ( effectName !== method && element[ effectName ] ) {
- element[ effectName ]( options.duration, options.easing, callback );
- } else {
- element.queue(function( next ) {
- $( this )[ method ]();
- if ( callback ) {
- callback.call( element[ 0 ] );
- }
- next();
- });
- }
- };
-});
-
-})( jQuery );
http://git-wip-us.apache.org/repos/asf/cordova-plugins/blob/5d951c9e/local-webserver/src/ios/GCDWebServer/GCDWebUploader/GCDWebUploader.bundle/js/respond.min.js
----------------------------------------------------------------------
diff --git a/local-webserver/src/ios/GCDWebServer/GCDWebUploader/GCDWebUploader.bundle/js/respond.min.js b/local-webserver/src/ios/GCDWebServer/GCDWebUploader/GCDWebUploader.bundle/js/respond.min.js
deleted file mode 100755
index 80a7b69..0000000
--- a/local-webserver/src/ios/GCDWebServer/GCDWebUploader/GCDWebUploader.bundle/js/respond.min.js
+++ /dev/null
@@ -1,5 +0,0 @@
-/*! Respond.js v1.4.2: min/max-width media query polyfill * Copyright 2013 Scott Jehl
- * Licensed under https://github.com/scottjehl/Respond/blob/master/LICENSE-MIT
- * */
-
-!function(a){"use strict";a.matchMedia=a.matchMedia||function(a){var b,c=a.documentElement,d=c.firstElementChild||c.firstChild,e=a.createElement("body"),f=a.createElement("div");return f.id="mq-test-1",f.style.cssText="position:absolute;top:-100em",e.style.background="none",e.appendChild(f),function(a){return f.innerHTML='­<style media="'+a+'"> #mq-test-1 { width: 42px; }</style>',c.insertBefore(e,d),b=42===f.offsetWidth,c.removeChild(e),{matches:b,media:a}}}(a.document)}(this),function(a){"use strict";function b(){u(!0)}var c={};a.respond=c,c.update=function(){};var d=[],e=function(){var b=!1;try{b=new a.XMLHttpRequest}catch(c){b=new a.ActiveXObject("Microsoft.XMLHTTP")}return function(){return b}}(),f=function(a,b){var c=e();c&&(c.open("GET",a,!0),c.onreadystatechange=function(){4!==c.readyState||200!==c.status&&304!==c.status||b(c.responseText)},4!==c.readyState&&c.send(null))};if(c.ajax=f,c.queue=d,c.regex={media:/@media[^\{]+\{([^\{\}]*\{[^\}\{]*\})+/gi,keyframes:/@(?:\-(?:
o|moz|webkit)\-)?keyframes[^\{]+\{(?:[^\{\}]*\{[^\}\{]*\})+[^\}]*\}/gi,urls:/(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g,findStyles:/@media *([^\{]+)\{([\S\s]+?)$/,only:/(only\s+)?([a-zA-Z]+)\s?/,minw:/\([\s]*min\-width\s*:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/,maxw:/\([\s]*max\-width\s*:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/},c.mediaQueriesSupported=a.matchMedia&&null!==a.matchMedia("only all")&&a.matchMedia("only all").matches,!c.mediaQueriesSupported){var g,h,i,j=a.document,k=j.documentElement,l=[],m=[],n=[],o={},p=30,q=j.getElementsByTagName("head")[0]||k,r=j.getElementsByTagName("base")[0],s=q.getElementsByTagName("link"),t=function(){var a,b=j.createElement("div"),c=j.body,d=k.style.fontSize,e=c&&c.style.fontSize,f=!1;return b.style.cssText="position:absolute;font-size:1em;width:1em",c||(c=f=j.createElement("body"),c.style.background="none"),k.style.fontSize="100%",c.style.fontSize="100%",c.appendChild(b),f&&k.insertBefore(c,k.firstChild),a=b.offsetWidth,f?k.removeChild(c):c.removeC
hild(b),k.style.fontSize=d,e&&(c.style.fontSize=e),a=i=parseFloat(a)},u=function(b){var c="clientWidth",d=k[c],e="CSS1Compat"===j.compatMode&&d||j.body[c]||d,f={},o=s[s.length-1],r=(new Date).getTime();if(b&&g&&p>r-g)return a.clearTimeout(h),h=a.setTimeout(u,p),void 0;g=r;for(var v in l)if(l.hasOwnProperty(v)){var w=l[v],x=w.minw,y=w.maxw,z=null===x,A=null===y,B="em";x&&(x=parseFloat(x)*(x.indexOf(B)>-1?i||t():1)),y&&(y=parseFloat(y)*(y.indexOf(B)>-1?i||t():1)),w.hasquery&&(z&&A||!(z||e>=x)||!(A||y>=e))||(f[w.media]||(f[w.media]=[]),f[w.media].push(m[w.rules]))}for(var C in n)n.hasOwnProperty(C)&&n[C]&&n[C].parentNode===q&&q.removeChild(n[C]);n.length=0;for(var D in f)if(f.hasOwnProperty(D)){var E=j.createElement("style"),F=f[D].join("\n");E.type="text/css",E.media=D,q.insertBefore(E,o.nextSibling),E.styleSheet?E.styleSheet.cssText=F:E.appendChild(j.createTextNode(F)),n.push(E)}},v=function(a,b,d){var e=a.replace(c.regex.keyframes,"").match(c.regex.media),f=e&&e.length||0;b=b.substr
ing(0,b.lastIndexOf("/"));var g=function(a){return a.replace(c.regex.urls,"$1"+b+"$2$3")},h=!f&&d;b.length&&(b+="/"),h&&(f=1);for(var i=0;f>i;i++){var j,k,n,o;h?(j=d,m.push(g(a))):(j=e[i].match(c.regex.findStyles)&&RegExp.$1,m.push(RegExp.$2&&g(RegExp.$2))),n=j.split(","),o=n.length;for(var p=0;o>p;p++)k=n[p],l.push({media:k.split("(")[0].match(c.regex.only)&&RegExp.$2||"all",rules:m.length-1,hasquery:k.indexOf("(")>-1,minw:k.match(c.regex.minw)&&parseFloat(RegExp.$1)+(RegExp.$2||""),maxw:k.match(c.regex.maxw)&&parseFloat(RegExp.$1)+(RegExp.$2||"")})}u()},w=function(){if(d.length){var b=d.shift();f(b.href,function(c){v(c,b.href,b.media),o[b.href]=!0,a.setTimeout(function(){w()},0)})}},x=function(){for(var b=0;b<s.length;b++){var c=s[b],e=c.href,f=c.media,g=c.rel&&"stylesheet"===c.rel.toLowerCase();e&&g&&!o[e]&&(c.styleSheet&&c.styleSheet.rawCssText?(v(c.styleSheet.rawCssText,e,f),o[e]=!0):(!/^([a-zA-Z:]*\/\/)/.test(e)&&!r||e.replace(RegExp.$1,"").split("/")[0]===a.location.host)&&("
//"===e.substring(0,2)&&(e=a.location.protocol+e),d.push({href:e,media:f})))}w()};x(),c.update=x,c.getEmValue=t,a.addEventListener?a.addEventListener("resize",b,!1):a.attachEvent&&a.attachEvent("onresize",b)}}(this);
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-plugins/blob/5d951c9e/local-webserver/src/ios/GCDWebServer/GCDWebUploader/GCDWebUploader.bundle/js/tmpl.min.js
----------------------------------------------------------------------
diff --git a/local-webserver/src/ios/GCDWebServer/GCDWebUploader/GCDWebUploader.bundle/js/tmpl.min.js b/local-webserver/src/ios/GCDWebServer/GCDWebUploader/GCDWebUploader.bundle/js/tmpl.min.js
deleted file mode 100644
index 64bb2a3..0000000
--- a/local-webserver/src/ios/GCDWebServer/GCDWebUploader/GCDWebUploader.bundle/js/tmpl.min.js
+++ /dev/null
@@ -1 +0,0 @@
-!function(a){"use strict";var b=function(a,c){var d=/[^\w\-\.:]/.test(a)?new Function(b.arg+",tmpl","var _e=tmpl.encode"+b.helper+",_s='"+a.replace(b.regexp,b.func)+"';return _s;"):b.cache[a]=b.cache[a]||b(b.load(a));return c?d(c,b):function(a){return d(a,b)}};b.cache={},b.load=function(a){return document.getElementById(a).innerHTML},b.regexp=/([\s'\\])(?!(?:[^{]|\{(?!%))*%\})|(?:\{%(=|#)([\s\S]+?)%\})|(\{%)|(%\})/g,b.func=function(a,b,c,d,e,f){return b?{"\n":"\\n","\r":"\\r"," ":"\\t"," ":" "}[b]||"\\"+b:c?"="===c?"'+_e("+d+")+'":"'+("+d+"==null?'':"+d+")+'":e?"';":f?"_s+='":void 0},b.encReg=/[<>&"'\x00]/g,b.encMap={"<":"<",">":">","&":"&",'"':""","'":"'"},b.encode=function(a){return(null==a?"":""+a).replace(b.encReg,function(a){return b.encMap[a]||""})},b.arg="o",b.helper=",print=function(s,e){_s+=e?(s==null?'':s):_e(s);},include=function(s,d){_s+=tmpl(s,d);}","function"==typeof define&&define.amd?define(function(){return b}):a.tmpl=b}(this);
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-plugins/blob/5d951c9e/local-webserver/src/ios/GCDWebServer/GCDWebUploader/GCDWebUploader.h
----------------------------------------------------------------------
diff --git a/local-webserver/src/ios/GCDWebServer/GCDWebUploader/GCDWebUploader.h b/local-webserver/src/ios/GCDWebServer/GCDWebUploader/GCDWebUploader.h
deleted file mode 100644
index d2c92e9..0000000
--- a/local-webserver/src/ios/GCDWebServer/GCDWebUploader/GCDWebUploader.h
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- Copyright (c) 2012-2015, Pierre-Olivier Latour
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- * The name of Pierre-Olivier Latour may not be used to endorse
- or promote products derived from this software without specific
- prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "GCDWebServer.h"
-
-@class GCDWebUploader;
-
-/**
- * Delegate methods for GCDWebUploader.
- *
- * @warning These methods are always called on the main thread in a serialized way.
- */
-@protocol GCDWebUploaderDelegate <GCDWebServerDelegate>
-@optional
-
-/**
- * This method is called whenever a file has been downloaded.
- */
-- (void)webUploader:(GCDWebUploader*)uploader didDownloadFileAtPath:(NSString*)path;
-
-/**
- * This method is called whenever a file has been uploaded.
- */
-- (void)webUploader:(GCDWebUploader*)uploader didUploadFileAtPath:(NSString*)path;
-
-/**
- * This method is called whenever a file or directory has been moved.
- */
-- (void)webUploader:(GCDWebUploader*)uploader didMoveItemFromPath:(NSString*)fromPath toPath:(NSString*)toPath;
-
-/**
- * This method is called whenever a file or directory has been deleted.
- */
-- (void)webUploader:(GCDWebUploader*)uploader didDeleteItemAtPath:(NSString*)path;
-
-/**
- * This method is called whenever a directory has been created.
- */
-- (void)webUploader:(GCDWebUploader*)uploader didCreateDirectoryAtPath:(NSString*)path;
-
-@end
-
-/**
- * The GCDWebUploader subclass of GCDWebServer implements an HTML 5 web browser
- * interface for uploading or downloading files, and moving or deleting files
- * or directories.
- *
- * See the README.md file for more information about the features of GCDWebUploader.
- *
- * @warning For GCDWebUploader to work, "GCDWebUploader.bundle" must be added
- * to the resources of the Xcode target.
- */
-@interface GCDWebUploader : GCDWebServer
-
-/**
- * Returns the upload directory as specified when the uploader was initialized.
- */
-@property(nonatomic, readonly) NSString* uploadDirectory;
-
-/**
- * Sets the delegate for the uploader.
- */
-@property(nonatomic, assign) id<GCDWebUploaderDelegate> delegate;
-
-/**
- * Sets which files are allowed to be operated on depending on their extension.
- *
- * The default value is nil i.e. all file extensions are allowed.
- */
-@property(nonatomic, copy) NSArray* allowedFileExtensions;
-
-/**
- * Sets if files and directories whose name start with a period are allowed to
- * be operated on.
- *
- * The default value is NO.
- */
-@property(nonatomic) BOOL allowHiddenItems;
-
-/**
- * Sets the title for the uploader web interface.
- *
- * The default value is the application name.
- *
- * @warning Any reserved HTML characters in the string value for this property
- * must have been replaced by character entities e.g. "&" becomes "&".
- */
-@property(nonatomic, copy) NSString* title;
-
-/**
- * Sets the header for the uploader web interface.
- *
- * The default value is the same as the title property.
- *
- * @warning Any reserved HTML characters in the string value for this property
- * must have been replaced by character entities e.g. "&" becomes "&".
- */
-@property(nonatomic, copy) NSString* header;
-
-/**
- * Sets the prologue for the uploader web interface.
- *
- * The default value is a short help text.
- *
- * @warning The string value for this property must be raw HTML
- * e.g. "<p>Some text</p>"
- */
-@property(nonatomic, copy) NSString* prologue;
-
-/**
- * Sets the epilogue for the uploader web interface.
- *
- * The default value is nil i.e. no epilogue.
- *
- * @warning The string value for this property must be raw HTML
- * e.g. "<p>Some text</p>"
- */
-@property(nonatomic, copy) NSString* epilogue;
-
-/**
- * Sets the footer for the uploader web interface.
- *
- * The default value is the application name and version.
- *
- * @warning Any reserved HTML characters in the string value for this property
- * must have been replaced by character entities e.g. "&" becomes "&".
- */
-@property(nonatomic, copy) NSString* footer;
-
-/**
- * This method is the designated initializer for the class.
- */
-- (instancetype)initWithUploadDirectory:(NSString*)path;
-
-@end
-
-/**
- * Hooks to customize the behavior of GCDWebUploader.
- *
- * @warning These methods can be called on any GCD thread.
- */
-@interface GCDWebUploader (Subclassing)
-
-/**
- * This method is called to check if a file upload is allowed to complete.
- * The uploaded file is available for inspection at "tempPath".
- *
- * The default implementation returns YES.
- */
-- (BOOL)shouldUploadFileAtPath:(NSString*)path withTemporaryFile:(NSString*)tempPath;
-
-/**
- * This method is called to check if a file or directory is allowed to be moved.
- *
- * The default implementation returns YES.
- */
-- (BOOL)shouldMoveItemFromPath:(NSString*)fromPath toPath:(NSString*)toPath;
-
-/**
- * This method is called to check if a file or directory is allowed to be deleted.
- *
- * The default implementation returns YES.
- */
-- (BOOL)shouldDeleteItemAtPath:(NSString*)path;
-
-/**
- * This method is called to check if a directory is allowed to be created.
- *
- * The default implementation returns YES.
- */
-- (BOOL)shouldCreateDirectoryAtPath:(NSString*)path;
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-plugins/blob/5d951c9e/local-webserver/src/ios/GCDWebServer/GCDWebUploader/GCDWebUploader.m
----------------------------------------------------------------------
diff --git a/local-webserver/src/ios/GCDWebServer/GCDWebUploader/GCDWebUploader.m b/local-webserver/src/ios/GCDWebServer/GCDWebUploader/GCDWebUploader.m
deleted file mode 100644
index 9bb4453..0000000
--- a/local-webserver/src/ios/GCDWebServer/GCDWebUploader/GCDWebUploader.m
+++ /dev/null
@@ -1,419 +0,0 @@
-/*
- Copyright (c) 2012-2015, Pierre-Olivier Latour
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- * The name of Pierre-Olivier Latour may not be used to endorse
- or promote products derived from this software without specific
- prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#if !__has_feature(objc_arc)
-#error GCDWebUploader requires ARC
-#endif
-
-#import <TargetConditionals.h>
-#if TARGET_OS_IPHONE
-#import <UIKit/UIKit.h>
-#else
-#import <SystemConfiguration/SystemConfiguration.h>
-#endif
-
-#import "GCDWebUploader.h"
-
-#import "GCDWebServerDataRequest.h"
-#import "GCDWebServerMultiPartFormRequest.h"
-#import "GCDWebServerURLEncodedFormRequest.h"
-
-#import "GCDWebServerDataResponse.h"
-#import "GCDWebServerErrorResponse.h"
-#import "GCDWebServerFileResponse.h"
-
-@interface GCDWebUploader () {
-@private
- NSString* _uploadDirectory;
- NSArray* _allowedExtensions;
- BOOL _allowHidden;
- NSString* _title;
- NSString* _header;
- NSString* _prologue;
- NSString* _epilogue;
- NSString* _footer;
-}
-@end
-
-@implementation GCDWebUploader (Methods)
-
-// Must match implementation in GCDWebDAVServer
-- (BOOL)_checkSandboxedPath:(NSString*)path {
- return [[path stringByStandardizingPath] hasPrefix:_uploadDirectory];
-}
-
-- (BOOL)_checkFileExtension:(NSString*)fileName {
- if (_allowedExtensions && ![_allowedExtensions containsObject:[[fileName pathExtension] lowercaseString]]) {
- return NO;
- }
- return YES;
-}
-
-- (NSString*) _uniquePathForPath:(NSString*)path {
- if ([[NSFileManager defaultManager] fileExistsAtPath:path]) {
- NSString* directory = [path stringByDeletingLastPathComponent];
- NSString* file = [path lastPathComponent];
- NSString* base = [file stringByDeletingPathExtension];
- NSString* extension = [file pathExtension];
- int retries = 0;
- do {
- if (extension.length) {
- path = [directory stringByAppendingPathComponent:[[base stringByAppendingFormat:@" (%i)", ++retries] stringByAppendingPathExtension:extension]];
- } else {
- path = [directory stringByAppendingPathComponent:[base stringByAppendingFormat:@" (%i)", ++retries]];
- }
- } while ([[NSFileManager defaultManager] fileExistsAtPath:path]);
- }
- return path;
-}
-
-- (GCDWebServerResponse*)listDirectory:(GCDWebServerRequest*)request {
- NSString* relativePath = [[request query] objectForKey:@"path"];
- NSString* absolutePath = [_uploadDirectory stringByAppendingPathComponent:relativePath];
- BOOL isDirectory = NO;
- if (![self _checkSandboxedPath:absolutePath] || ![[NSFileManager defaultManager] fileExistsAtPath:absolutePath isDirectory:&isDirectory]) {
- return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_NotFound message:@"\"%@\" does not exist", relativePath];
- }
- if (!isDirectory) {
- return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_BadRequest message:@"\"%@\" is not a directory", relativePath];
- }
-
- NSString* directoryName = [absolutePath lastPathComponent];
- if (!_allowHidden && [directoryName hasPrefix:@"."]) {
- return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_Forbidden message:@"Listing directory name \"%@\" is not allowed", directoryName];
- }
-
- NSError* error = nil;
- NSArray* contents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:absolutePath error:&error];
- if (contents == nil) {
- return [GCDWebServerErrorResponse responseWithServerError:kGCDWebServerHTTPStatusCode_InternalServerError underlyingError:error message:@"Failed listing directory \"%@\"", relativePath];
- }
-
- NSMutableArray* array = [NSMutableArray array];
- for (NSString* item in [contents sortedArrayUsingSelector:@selector(localizedStandardCompare:)]) {
- if (_allowHidden || ![item hasPrefix:@"."]) {
- NSDictionary* attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:[absolutePath stringByAppendingPathComponent:item] error:NULL];
- NSString* type = [attributes objectForKey:NSFileType];
- if ([type isEqualToString:NSFileTypeRegular] && [self _checkFileExtension:item]) {
- [array addObject:@{
- @"path": [relativePath stringByAppendingPathComponent:item],
- @"name": item,
- @"size": [attributes objectForKey:NSFileSize]
- }];
- } else if ([type isEqualToString:NSFileTypeDirectory]) {
- [array addObject:@{
- @"path": [[relativePath stringByAppendingPathComponent:item] stringByAppendingString:@"/"],
- @"name": item
- }];
- }
- }
- }
- return [GCDWebServerDataResponse responseWithJSONObject:array];
-}
-
-- (GCDWebServerResponse*)downloadFile:(GCDWebServerRequest*)request {
- NSString* relativePath = [[request query] objectForKey:@"path"];
- NSString* absolutePath = [_uploadDirectory stringByAppendingPathComponent:relativePath];
- BOOL isDirectory = NO;
- if (![self _checkSandboxedPath:absolutePath] || ![[NSFileManager defaultManager] fileExistsAtPath:absolutePath isDirectory:&isDirectory]) {
- return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_NotFound message:@"\"%@\" does not exist", relativePath];
- }
- if (isDirectory) {
- return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_BadRequest message:@"\"%@\" is a directory", relativePath];
- }
-
- NSString* fileName = [absolutePath lastPathComponent];
- if (([fileName hasPrefix:@"."] && !_allowHidden) || ![self _checkFileExtension:fileName]) {
- return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_Forbidden message:@"Downlading file name \"%@\" is not allowed", fileName];
- }
-
- if ([self.delegate respondsToSelector:@selector(webUploader:didDownloadFileAtPath: )]) {
- dispatch_async(dispatch_get_main_queue(), ^{
- [self.delegate webUploader:self didDownloadFileAtPath:absolutePath];
- });
- }
- return [GCDWebServerFileResponse responseWithFile:absolutePath isAttachment:YES];
-}
-
-- (GCDWebServerResponse*)uploadFile:(GCDWebServerMultiPartFormRequest*)request {
- NSRange range = [[request.headers objectForKey:@"Accept"] rangeOfString:@"application/json" options:NSCaseInsensitiveSearch];
- NSString* contentType = (range.location != NSNotFound ? @"application/json" : @"text/plain; charset=utf-8"); // Required when using iFrame transport (see https://github.com/blueimp/jQuery-File-Upload/wiki/Setup)
-
- GCDWebServerMultiPartFile* file = [request firstFileForControlName:@"files[]"];
- if ((!_allowHidden && [file.fileName hasPrefix:@"."]) || ![self _checkFileExtension:file.fileName]) {
- return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_Forbidden message:@"Uploaded file name \"%@\" is not allowed", file.fileName];
- }
- NSString* relativePath = [[request firstArgumentForControlName:@"path"] string];
- NSString* absolutePath = [self _uniquePathForPath:[[_uploadDirectory stringByAppendingPathComponent:relativePath] stringByAppendingPathComponent:file.fileName]];
- if (![self _checkSandboxedPath:absolutePath]) {
- return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_NotFound message:@"\"%@\" does not exist", relativePath];
- }
-
- if (![self shouldUploadFileAtPath:absolutePath withTemporaryFile:file.temporaryPath]) {
- return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_Forbidden message:@"Uploading file \"%@\" to \"%@\" is not permitted", file.fileName, relativePath];
- }
-
- NSError* error = nil;
- if (![[NSFileManager defaultManager] moveItemAtPath:file.temporaryPath toPath:absolutePath error:&error]) {
- return [GCDWebServerErrorResponse responseWithServerError:kGCDWebServerHTTPStatusCode_InternalServerError underlyingError:error message:@"Failed moving uploaded file to \"%@\"", relativePath];
- }
-
- if ([self.delegate respondsToSelector:@selector(webUploader:didUploadFileAtPath:)]) {
- dispatch_async(dispatch_get_main_queue(), ^{
- [self.delegate webUploader:self didUploadFileAtPath:absolutePath];
- });
- }
- return [GCDWebServerDataResponse responseWithJSONObject:@{} contentType:contentType];
-}
-
-- (GCDWebServerResponse*)moveItem:(GCDWebServerURLEncodedFormRequest*)request {
- NSString* oldRelativePath = [request.arguments objectForKey:@"oldPath"];
- NSString* oldAbsolutePath = [_uploadDirectory stringByAppendingPathComponent:oldRelativePath];
- BOOL isDirectory = NO;
- if (![self _checkSandboxedPath:oldAbsolutePath] || ![[NSFileManager defaultManager] fileExistsAtPath:oldAbsolutePath isDirectory:&isDirectory]) {
- return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_NotFound message:@"\"%@\" does not exist", oldRelativePath];
- }
-
- NSString* newRelativePath = [request.arguments objectForKey:@"newPath"];
- NSString* newAbsolutePath = [self _uniquePathForPath:[_uploadDirectory stringByAppendingPathComponent:newRelativePath]];
- if (![self _checkSandboxedPath:newAbsolutePath]) {
- return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_NotFound message:@"\"%@\" does not exist", newRelativePath];
- }
-
- NSString* itemName = [newAbsolutePath lastPathComponent];
- if ((!_allowHidden && [itemName hasPrefix:@"."]) || (!isDirectory && ![self _checkFileExtension:itemName])) {
- return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_Forbidden message:@"Moving to item name \"%@\" is not allowed", itemName];
- }
-
- if (![self shouldMoveItemFromPath:oldAbsolutePath toPath:newAbsolutePath]) {
- return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_Forbidden message:@"Moving \"%@\" to \"%@\" is not permitted", oldRelativePath, newRelativePath];
- }
-
- NSError* error = nil;
- if (![[NSFileManager defaultManager] moveItemAtPath:oldAbsolutePath toPath:newAbsolutePath error:&error]) {
- return [GCDWebServerErrorResponse responseWithServerError:kGCDWebServerHTTPStatusCode_InternalServerError underlyingError:error message:@"Failed moving \"%@\" to \"%@\"", oldRelativePath, newRelativePath];
- }
-
- if ([self.delegate respondsToSelector:@selector(webUploader:didMoveItemFromPath:toPath:)]) {
- dispatch_async(dispatch_get_main_queue(), ^{
- [self.delegate webUploader:self didMoveItemFromPath:oldAbsolutePath toPath:newAbsolutePath];
- });
- }
- return [GCDWebServerDataResponse responseWithJSONObject:@{}];
-}
-
-- (GCDWebServerResponse*)deleteItem:(GCDWebServerURLEncodedFormRequest*)request {
- NSString* relativePath = [request.arguments objectForKey:@"path"];
- NSString* absolutePath = [_uploadDirectory stringByAppendingPathComponent:relativePath];
- BOOL isDirectory = NO;
- if (![self _checkSandboxedPath:absolutePath] || ![[NSFileManager defaultManager] fileExistsAtPath:absolutePath isDirectory:&isDirectory]) {
- return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_NotFound message:@"\"%@\" does not exist", relativePath];
- }
-
- NSString* itemName = [absolutePath lastPathComponent];
- if (([itemName hasPrefix:@"."] && !_allowHidden) || (!isDirectory && ![self _checkFileExtension:itemName])) {
- return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_Forbidden message:@"Deleting item name \"%@\" is not allowed", itemName];
- }
-
- if (![self shouldDeleteItemAtPath:absolutePath]) {
- return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_Forbidden message:@"Deleting \"%@\" is not permitted", relativePath];
- }
-
- NSError* error = nil;
- if (![[NSFileManager defaultManager] removeItemAtPath:absolutePath error:&error]) {
- return [GCDWebServerErrorResponse responseWithServerError:kGCDWebServerHTTPStatusCode_InternalServerError underlyingError:error message:@"Failed deleting \"%@\"", relativePath];
- }
-
- if ([self.delegate respondsToSelector:@selector(webUploader:didDeleteItemAtPath:)]) {
- dispatch_async(dispatch_get_main_queue(), ^{
- [self.delegate webUploader:self didDeleteItemAtPath:absolutePath];
- });
- }
- return [GCDWebServerDataResponse responseWithJSONObject:@{}];
-}
-
-- (GCDWebServerResponse*)createDirectory:(GCDWebServerURLEncodedFormRequest*)request {
- NSString* relativePath = [request.arguments objectForKey:@"path"];
- NSString* absolutePath = [self _uniquePathForPath:[_uploadDirectory stringByAppendingPathComponent:relativePath]];
- if (![self _checkSandboxedPath:absolutePath]) {
- return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_NotFound message:@"\"%@\" does not exist", relativePath];
- }
-
- NSString* directoryName = [absolutePath lastPathComponent];
- if (!_allowHidden && [directoryName hasPrefix:@"."]) {
- return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_Forbidden message:@"Creating directory name \"%@\" is not allowed", directoryName];
- }
-
- if (![self shouldCreateDirectoryAtPath:absolutePath]) {
- return [GCDWebServerErrorResponse responseWithClientError:kGCDWebServerHTTPStatusCode_Forbidden message:@"Creating directory \"%@\" is not permitted", relativePath];
- }
-
- NSError* error = nil;
- if (![[NSFileManager defaultManager] createDirectoryAtPath:absolutePath withIntermediateDirectories:NO attributes:nil error:&error]) {
- return [GCDWebServerErrorResponse responseWithServerError:kGCDWebServerHTTPStatusCode_InternalServerError underlyingError:error message:@"Failed creating directory \"%@\"", relativePath];
- }
-
- if ([self.delegate respondsToSelector:@selector(webUploader:didCreateDirectoryAtPath:)]) {
- dispatch_async(dispatch_get_main_queue(), ^{
- [self.delegate webUploader:self didCreateDirectoryAtPath:absolutePath];
- });
- }
- return [GCDWebServerDataResponse responseWithJSONObject:@{}];
-}
-
-@end
-
-@implementation GCDWebUploader
-
-@synthesize uploadDirectory=_uploadDirectory, allowedFileExtensions=_allowedExtensions, allowHiddenItems=_allowHidden,
- title=_title, header=_header, prologue=_prologue, epilogue=_epilogue, footer=_footer;
-
-@dynamic delegate;
-
-- (instancetype)initWithUploadDirectory:(NSString*)path {
- if ((self = [super init])) {
- NSBundle* siteBundle = [NSBundle bundleWithPath:[[NSBundle bundleForClass:[GCDWebUploader class]] pathForResource:@"GCDWebUploader" ofType:@"bundle"]];
- if (siteBundle == nil) {
- return nil;
- }
- _uploadDirectory = [[path stringByStandardizingPath] copy];
- GCDWebUploader* __unsafe_unretained server = self;
-
- // Resource files
- [self addGETHandlerForBasePath:@"/" directoryPath:[siteBundle resourcePath] indexFilename:nil cacheAge:3600 allowRangeRequests:NO];
-
- // Web page
- [self addHandlerForMethod:@"GET" path:@"/" requestClass:[GCDWebServerRequest class] processBlock:^GCDWebServerResponse *(GCDWebServerRequest* request) {
-
-#if TARGET_OS_IPHONE
- NSString* device = [[UIDevice currentDevice] name];
-#else
- NSString* device = CFBridgingRelease(SCDynamicStoreCopyComputerName(NULL, NULL));
-#endif
- NSString* title = server.title;
- if (title == nil) {
- title = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"];
- if (title == nil) {
- title = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"];
- }
-#if !TARGET_OS_IPHONE
- if (title == nil) {
- title = [[NSProcessInfo processInfo] processName];
- }
-#endif
- }
- NSString* header = server.header;
- if (header == nil) {
- header = title;
- }
- NSString* prologue = server.prologue;
- if (prologue == nil) {
- prologue = [siteBundle localizedStringForKey:@"PROLOGUE" value:@"" table:nil];
- }
- NSString* epilogue = server.epilogue;
- if (epilogue == nil) {
- epilogue = [siteBundle localizedStringForKey:@"EPILOGUE" value:@"" table:nil];
- }
- NSString* footer = server.footer;
- if (footer == nil) {
- NSString* name = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"];
- NSString* version = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
-#if !TARGET_OS_IPHONE
- if (!name && !version) {
- name = @"OS X";
- version = [[NSProcessInfo processInfo] operatingSystemVersionString];
- }
-#endif
- footer = [NSString stringWithFormat:[siteBundle localizedStringForKey:@"FOOTER_FORMAT" value:@"" table:nil], name, version];
- }
- return [GCDWebServerDataResponse responseWithHTMLTemplate:[siteBundle pathForResource:@"index" ofType:@"html"]
- variables:@{
- @"device": device,
- @"title": title,
- @"header": header,
- @"prologue": prologue,
- @"epilogue": epilogue,
- @"footer": footer
- }];
-
- }];
-
- // File listing
- [self addHandlerForMethod:@"GET" path:@"/list" requestClass:[GCDWebServerRequest class] processBlock:^GCDWebServerResponse *(GCDWebServerRequest* request) {
- return [server listDirectory:request];
- }];
-
- // File download
- [self addHandlerForMethod:@"GET" path:@"/download" requestClass:[GCDWebServerRequest class] processBlock:^GCDWebServerResponse *(GCDWebServerRequest* request) {
- return [server downloadFile:request];
- }];
-
- // File upload
- [self addHandlerForMethod:@"POST" path:@"/upload" requestClass:[GCDWebServerMultiPartFormRequest class] processBlock:^GCDWebServerResponse *(GCDWebServerRequest* request) {
- return [server uploadFile:(GCDWebServerMultiPartFormRequest*)request];
- }];
-
- // File and folder moving
- [self addHandlerForMethod:@"POST" path:@"/move" requestClass:[GCDWebServerURLEncodedFormRequest class] processBlock:^GCDWebServerResponse *(GCDWebServerRequest* request) {
- return [server moveItem:(GCDWebServerURLEncodedFormRequest*)request];
- }];
-
- // File and folder deletion
- [self addHandlerForMethod:@"POST" path:@"/delete" requestClass:[GCDWebServerURLEncodedFormRequest class] processBlock:^GCDWebServerResponse *(GCDWebServerRequest* request) {
- return [server deleteItem:(GCDWebServerURLEncodedFormRequest*)request];
- }];
-
- // Directory creation
- [self addHandlerForMethod:@"POST" path:@"/create" requestClass:[GCDWebServerURLEncodedFormRequest class] processBlock:^GCDWebServerResponse *(GCDWebServerRequest* request) {
- return [server createDirectory:(GCDWebServerURLEncodedFormRequest*)request];
- }];
-
- }
- return self;
-}
-
-@end
-
-@implementation GCDWebUploader (Subclassing)
-
-- (BOOL)shouldUploadFileAtPath:(NSString*)path withTemporaryFile:(NSString*)tempPath {
- return YES;
-}
-
-- (BOOL)shouldMoveItemFromPath:(NSString*)fromPath toPath:(NSString*)toPath {
- return YES;
-}
-
-- (BOOL)shouldDeleteItemAtPath:(NSString*)path {
- return YES;
-}
-
-- (BOOL)shouldCreateDirectoryAtPath:(NSString*)path {
- return YES;
-}
-
-@end
http://git-wip-us.apache.org/repos/asf/cordova-plugins/blob/5d951c9e/local-webserver/src/ios/GCDWebServer/LICENSE
----------------------------------------------------------------------
diff --git a/local-webserver/src/ios/GCDWebServer/LICENSE b/local-webserver/src/ios/GCDWebServer/LICENSE
deleted file mode 100644
index 12335de..0000000
--- a/local-webserver/src/ios/GCDWebServer/LICENSE
+++ /dev/null
@@ -1,24 +0,0 @@
-Copyright (c) 2012-2014, Pierre-Olivier Latour
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- * The name of Pierre-Olivier Latour may not be used to endorse
- or promote products derived from this software without specific
- prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY
-DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
http://git-wip-us.apache.org/repos/asf/cordova-plugins/blob/5d951c9e/local-webserver/src/ios/GCDWebServer/Mac/main.m
----------------------------------------------------------------------
diff --git a/local-webserver/src/ios/GCDWebServer/Mac/main.m b/local-webserver/src/ios/GCDWebServer/Mac/main.m
deleted file mode 100644
index 33b25e5..0000000
--- a/local-webserver/src/ios/GCDWebServer/Mac/main.m
+++ /dev/null
@@ -1,442 +0,0 @@
-/*
- Copyright (c) 2012-2015, Pierre-Olivier Latour
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- * The name of Pierre-Olivier Latour may not be used to endorse
- or promote products derived from this software without specific
- prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <libgen.h>
-
-#import "GCDWebServer.h"
-
-#import "GCDWebServerDataRequest.h"
-#import "GCDWebServerURLEncodedFormRequest.h"
-#import "GCDWebServerMultiPartFormRequest.h"
-
-#import "GCDWebServerDataResponse.h"
-#import "GCDWebServerStreamedResponse.h"
-
-#import "GCDWebDAVServer.h"
-
-#import "GCDWebUploader.h"
-
-#ifndef __GCDWEBSERVER_ENABLE_TESTING__
-#error __GCDWEBSERVER_ENABLE_TESTING__ must be defined
-#endif
-
-typedef enum {
- kMode_WebServer = 0,
- kMode_HTMLPage,
- kMode_HTMLForm,
- kMode_HTMLFileUpload,
- kMode_WebDAV,
- kMode_WebUploader,
- kMode_StreamingResponse,
- kMode_AsyncResponse
-} Mode;
-
-@interface Delegate : NSObject <GCDWebServerDelegate, GCDWebDAVServerDelegate, GCDWebUploaderDelegate>
-@end
-
-@implementation Delegate
-
-- (void)_logDelegateCall:(SEL)selector {
- fprintf(stdout, "<DELEGATE METHOD \"%s\" CALLED>\n", [NSStringFromSelector(selector) UTF8String]);
-}
-
-- (void)webServerDidStart:(GCDWebServer*)server {
- [self _logDelegateCall:_cmd];
-}
-
-- (void)webServerDidCompleteBonjourRegistration:(GCDWebServer*)server {
- [self _logDelegateCall:_cmd];
-}
-
-- (void)webServerDidUpdateNATPortMapping:(GCDWebServer*)server {
- [self _logDelegateCall:_cmd];
-}
-
-- (void)webServerDidConnect:(GCDWebServer*)server {
- [self _logDelegateCall:_cmd];
-}
-
-- (void)webServerDidDisconnect:(GCDWebServer*)server {
- [self _logDelegateCall:_cmd];
-}
-
-- (void)webServerDidStop:(GCDWebServer*)server {
- [self _logDelegateCall:_cmd];
-}
-
-- (void)davServer:(GCDWebDAVServer*)server didDownloadFileAtPath:(NSString*)path {
- [self _logDelegateCall:_cmd];
-}
-
-- (void)davServer:(GCDWebDAVServer*)server didUploadFileAtPath:(NSString*)path {
- [self _logDelegateCall:_cmd];
-}
-
-- (void)davServer:(GCDWebDAVServer*)server didMoveItemFromPath:(NSString*)fromPath toPath:(NSString*)toPath {
- [self _logDelegateCall:_cmd];
-}
-
-- (void)davServer:(GCDWebDAVServer*)server didCopyItemFromPath:(NSString*)fromPath toPath:(NSString*)toPath {
- [self _logDelegateCall:_cmd];
-}
-
-- (void)davServer:(GCDWebDAVServer*)server didDeleteItemAtPath:(NSString*)path {
- [self _logDelegateCall:_cmd];
-}
-
-- (void)davServer:(GCDWebDAVServer*)server didCreateDirectoryAtPath:(NSString*)path {
- [self _logDelegateCall:_cmd];
-}
-
-- (void)webUploader:(GCDWebUploader*)uploader didDownloadFileAtPath:(NSString*)path {
- [self _logDelegateCall:_cmd];
-}
-
-- (void)webUploader:(GCDWebUploader*)uploader didUploadFileAtPath:(NSString*)path {
- [self _logDelegateCall:_cmd];
-}
-
-- (void)webUploader:(GCDWebUploader*)uploader didMoveItemFromPath:(NSString*)fromPath toPath:(NSString*)toPath {
- [self _logDelegateCall:_cmd];
-}
-
-- (void)webUploader:(GCDWebUploader*)uploader didDeleteItemAtPath:(NSString*)path {
- [self _logDelegateCall:_cmd];
-}
-
-- (void)webUploader:(GCDWebUploader*)uploader didCreateDirectoryAtPath:(NSString*)path {
- [self _logDelegateCall:_cmd];
-}
-
-@end
-
-int main(int argc, const char* argv[]) {
- int result = -1;
- @autoreleasepool {
- Mode mode = kMode_WebServer;
- BOOL recording = NO;
- NSString* rootDirectory = NSHomeDirectory();
- NSString* testDirectory = nil;
- NSString* authenticationMethod = nil;
- NSString* authenticationRealm = nil;
- NSString* authenticationUser = nil;
- NSString* authenticationPassword = nil;
- BOOL bindToLocalhost = NO;
- BOOL requestNATPortMapping = NO;
-
- if (argc == 1) {
- fprintf(stdout, "Usage: %s [-mode webServer | htmlPage | htmlForm | htmlFileUpload | webDAV | webUploader | streamingResponse | asyncResponse] [-record] [-root directory] [-tests directory] [-authenticationMethod Basic | Digest] [-authenticationRealm realm] [-authenticationUser user] [-authenticationPassword password] [--localhost]\n\n", basename((char*)argv[0]));
- } else {
- for (int i = 1; i < argc; ++i) {
- if (argv[i][0] != '-') {
- continue;
- }
- if (!strcmp(argv[i], "-mode") && (i + 1 < argc)) {
- ++i;
- if (!strcmp(argv[i], "webServer")) {
- mode = kMode_WebServer;
- } else if (!strcmp(argv[i], "htmlPage")) {
- mode = kMode_HTMLPage;
- } else if (!strcmp(argv[i], "htmlForm")) {
- mode = kMode_HTMLForm;
- } else if (!strcmp(argv[i], "htmlFileUpload")) {
- mode = kMode_HTMLFileUpload;
- } else if (!strcmp(argv[i], "webDAV")) {
- mode = kMode_WebDAV;
- } else if (!strcmp(argv[i], "webUploader")) {
- mode = kMode_WebUploader;
- } else if (!strcmp(argv[i], "streamingResponse")) {
- mode = kMode_StreamingResponse;
- } else if (!strcmp(argv[i], "asyncResponse")) {
- mode = kMode_AsyncResponse;
- }
- } else if (!strcmp(argv[i], "-record")) {
- recording = YES;
- } else if (!strcmp(argv[i], "-root") && (i + 1 < argc)) {
- ++i;
- rootDirectory = [[[NSFileManager defaultManager] stringWithFileSystemRepresentation:argv[i] length:strlen(argv[i])] stringByStandardizingPath];
- } else if (!strcmp(argv[i], "-tests") && (i + 1 < argc)) {
- ++i;
- testDirectory = [[[NSFileManager defaultManager] stringWithFileSystemRepresentation:argv[i] length:strlen(argv[i])] stringByStandardizingPath];
- } else if (!strcmp(argv[i], "-authenticationMethod") && (i + 1 < argc)) {
- ++i;
- authenticationMethod = [NSString stringWithUTF8String:argv[i]];
- } else if (!strcmp(argv[i], "-authenticationRealm") && (i + 1 < argc)) {
- ++i;
- authenticationRealm = [NSString stringWithUTF8String:argv[i]];
- } else if (!strcmp(argv[i], "-authenticationUser") && (i + 1 < argc)) {
- ++i;
- authenticationUser = [NSString stringWithUTF8String:argv[i]];
- } else if (!strcmp(argv[i], "-authenticationPassword") && (i + 1 < argc)) {
- ++i;
- authenticationPassword = [NSString stringWithUTF8String:argv[i]];
- } else if (!strcmp(argv[i], "--localhost")) {
- bindToLocalhost = YES;
- } else if (!strcmp(argv[i], "--nat")) {
- requestNATPortMapping = YES;
- }
- }
- }
-
- GCDWebServer* webServer = nil;
- switch (mode) {
-
- // Simply serve contents of home directory
- case kMode_WebServer: {
- fprintf(stdout, "Running in Web Server mode from \"%s\"", [rootDirectory UTF8String]);
- webServer = [[GCDWebServer alloc] init];
- [webServer addGETHandlerForBasePath:@"/" directoryPath:rootDirectory indexFilename:nil cacheAge:0 allowRangeRequests:YES];
- break;
- }
-
- // Renders a HTML page
- case kMode_HTMLPage: {
- fprintf(stdout, "Running in HTML Page mode");
- webServer = [[GCDWebServer alloc] init];
- [webServer addDefaultHandlerForMethod:@"GET"
- requestClass:[GCDWebServerRequest class]
- processBlock:^GCDWebServerResponse *(GCDWebServerRequest* request) {
-
- return [GCDWebServerDataResponse responseWithHTML:@"<html><body><p>Hello World</p></body></html>"];
-
- }];
- break;
- }
-
- // Implements an HTML form
- case kMode_HTMLForm: {
- fprintf(stdout, "Running in HTML Form mode");
- webServer = [[GCDWebServer alloc] init];
- [webServer addHandlerForMethod:@"GET"
- path:@"/"
- requestClass:[GCDWebServerRequest class]
- processBlock:^GCDWebServerResponse *(GCDWebServerRequest* request) {
-
- NSString* html = @" \
- <html><body> \
- <form name=\"input\" action=\"/\" method=\"post\" enctype=\"application/x-www-form-urlencoded\"> \
- Value: <input type=\"text\" name=\"value\"> \
- <input type=\"submit\" value=\"Submit\"> \
- </form> \
- </body></html> \
- ";
- return [GCDWebServerDataResponse responseWithHTML:html];
-
- }];
- [webServer addHandlerForMethod:@"POST"
- path:@"/"
- requestClass:[GCDWebServerURLEncodedFormRequest class]
- processBlock:^GCDWebServerResponse *(GCDWebServerRequest* request) {
-
- NSString* value = [[(GCDWebServerURLEncodedFormRequest*)request arguments] objectForKey:@"value"];
- NSString* html = [NSString stringWithFormat:@"<html><body><p>%@</p></body></html>", value];
- return [GCDWebServerDataResponse responseWithHTML:html];
-
- }];
- break;
- }
-
- // Implements HTML file upload
- case kMode_HTMLFileUpload: {
- fprintf(stdout, "Running in HTML File Upload mode");
- webServer = [[GCDWebServer alloc] init];
- NSString* formHTML = @" \
- <form name=\"input\" action=\"/\" method=\"post\" enctype=\"multipart/form-data\"> \
- <input type=\"hidden\" name=\"secret\" value=\"42\"> \
- <input type=\"file\" name=\"files\" multiple><br/> \
- <input type=\"submit\" value=\"Submit\"> \
- </form> \
- ";
- [webServer addHandlerForMethod:@"GET"
- path:@"/"
- requestClass:[GCDWebServerRequest class]
- processBlock:^GCDWebServerResponse *(GCDWebServerRequest* request) {
-
- NSString* html = [NSString stringWithFormat:@"<html><body>%@</body></html>", formHTML];
- return [GCDWebServerDataResponse responseWithHTML:html];
-
- }];
- [webServer addHandlerForMethod:@"POST"
- path:@"/"
- requestClass:[GCDWebServerMultiPartFormRequest class]
- processBlock:^GCDWebServerResponse *(GCDWebServerRequest* request) {
-
- NSMutableString* string = [NSMutableString string];
- for (GCDWebServerMultiPartArgument* argument in [(GCDWebServerMultiPartFormRequest*)request arguments]) {
- [string appendFormat:@"%@ = %@<br>", argument.controlName, argument.string];
- }
- for (GCDWebServerMultiPartFile* file in [(GCDWebServerMultiPartFormRequest*)request files]) {
- NSDictionary* attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:file.temporaryPath error:NULL];
- [string appendFormat:@"%@ = "%@" (%@ | %llu %@)<br>", file.controlName, file.fileName, file.mimeType,
- attributes.fileSize >= 1000 ? attributes.fileSize / 1000 : attributes.fileSize,
- attributes.fileSize >= 1000 ? @"KB" : @"Bytes"];
- };
- NSString* html = [NSString stringWithFormat:@"<html><body><p>%@</p><hr>%@</body></html>", string, formHTML];
- return [GCDWebServerDataResponse responseWithHTML:html];
-
- }];
- break;
- }
-
- // Serve home directory through WebDAV
- case kMode_WebDAV: {
- fprintf(stdout, "Running in WebDAV mode from \"%s\"", [rootDirectory UTF8String]);
- webServer = [[GCDWebDAVServer alloc] initWithUploadDirectory:rootDirectory];
- break;
- }
-
- // Serve home directory through web uploader
- case kMode_WebUploader: {
- fprintf(stdout, "Running in Web Uploader mode from \"%s\"", [rootDirectory UTF8String]);
- webServer = [[GCDWebUploader alloc] initWithUploadDirectory:rootDirectory];
- break;
- }
-
- // Test streaming responses
- case kMode_StreamingResponse: {
- fprintf(stdout, "Running in Streaming Response mode");
- webServer = [[GCDWebServer alloc] init];
- [webServer addHandlerForMethod:@"GET"
- path:@"/sync"
- requestClass:[GCDWebServerRequest class]
- processBlock:^GCDWebServerResponse *(GCDWebServerRequest* request) {
-
- __block int countDown = 10;
- return [GCDWebServerStreamedResponse responseWithContentType:@"text/plain" streamBlock:^NSData *(NSError** error) {
-
- usleep(100 * 1000);
- if (countDown) {
- return [[NSString stringWithFormat:@"%i\n", countDown--] dataUsingEncoding:NSUTF8StringEncoding];
- } else {
- return [NSData data];
- }
-
- }];
-
- }];
- [webServer addHandlerForMethod:@"GET"
- path:@"/async"
- requestClass:[GCDWebServerRequest class]
- processBlock:^GCDWebServerResponse *(GCDWebServerRequest* request) {
-
- __block int countDown = 10;
- return [GCDWebServerStreamedResponse responseWithContentType:@"text/plain" asyncStreamBlock:^(GCDWebServerBodyReaderCompletionBlock completionBlock) {
-
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
-
- NSData* data = countDown ? [[NSString stringWithFormat:@"%i\n", countDown--] dataUsingEncoding:NSUTF8StringEncoding] : [NSData data];
- completionBlock(data, nil);
-
- });
-
- }];
-
- }];
- break;
- }
-
- // Test async responses
- case kMode_AsyncResponse: {
- fprintf(stdout, "Running in Async Response mode");
- webServer = [[GCDWebServer alloc] init];
- [webServer addHandlerForMethod:@"GET"
- path:@"/async"
- requestClass:[GCDWebServerRequest class]
- asyncProcessBlock:^(GCDWebServerRequest* request, GCDWebServerCompletionBlock completionBlock) {
-
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- GCDWebServerDataResponse* response = [GCDWebServerDataResponse responseWithData:[@"Hello World!" dataUsingEncoding:NSUTF8StringEncoding] contentType:@"text/plain"];
- completionBlock(response);
- });
-
- }];
- [webServer addHandlerForMethod:@"GET"
- path:@"/async2"
- requestClass:[GCDWebServerRequest class]
- asyncProcessBlock:^(GCDWebServerRequest* request, GCDWebServerCompletionBlock handlerCompletionBlock) {
-
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-
- __block int countDown = 10;
- GCDWebServerStreamedResponse* response = [GCDWebServerStreamedResponse responseWithContentType:@"text/plain" asyncStreamBlock:^(GCDWebServerBodyReaderCompletionBlock readerCompletionBlock) {
-
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
-
- NSData* data = countDown ? [[NSString stringWithFormat:@"%i\n", countDown--] dataUsingEncoding:NSUTF8StringEncoding] : [NSData data];
- readerCompletionBlock(data, nil);
-
- });
-
- }];
- handlerCompletionBlock(response);
-
- });
-
- }];
- break;
- }
-
- }
-
- if (webServer) {
- Delegate* delegate = [[Delegate alloc] init];
- if (testDirectory) {
-#if DEBUG
- webServer.delegate = delegate;
-#endif
- fprintf(stdout, "<RUNNING TESTS FROM \"%s\">\n\n", [testDirectory UTF8String]);
- result = (int)[webServer runTestsWithOptions:@{GCDWebServerOption_Port: @8080} inDirectory:testDirectory];
- } else {
- webServer.delegate = delegate;
- if (recording) {
- fprintf(stdout, "<RECORDING ENABLED>\n");
- webServer.recordingEnabled = YES;
- }
- fprintf(stdout, "\n");
- NSMutableDictionary* options = [NSMutableDictionary dictionary];
- [options setObject:@8080 forKey:GCDWebServerOption_Port];
- [options setObject:@(requestNATPortMapping) forKey:GCDWebServerOption_RequestNATPortMapping];
- [options setObject:@(bindToLocalhost) forKey:GCDWebServerOption_BindToLocalhost];
- [options setObject:@"" forKey:GCDWebServerOption_BonjourName];
- if (authenticationUser && authenticationPassword) {
- [options setValue:authenticationRealm forKey:GCDWebServerOption_AuthenticationRealm];
- [options setObject:@{authenticationUser: authenticationPassword} forKey:GCDWebServerOption_AuthenticationAccounts];
- if ([authenticationMethod isEqualToString:@"Basic"]) {
- [options setObject:GCDWebServerAuthenticationMethod_Basic forKey:GCDWebServerOption_AuthenticationMethod];
- } else if ([authenticationMethod isEqualToString:@"Digest"]) {
- [options setObject:GCDWebServerAuthenticationMethod_DigestAccess forKey:GCDWebServerOption_AuthenticationMethod];
- }
- }
- if ([webServer runWithOptions:options error:NULL]) {
- result = 0;
- }
- }
- webServer.delegate = nil;
- }
- }
- return result;
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org