GithubHelp home page GithubHelp logo

floatinghotpot / cordova-httpd Goto Github PK

View Code? Open in Web Editor NEW
285.0 22.0 148.0 224 KB

Embed tiny web server into Cordova with a plugin

Objective-C 80.76% Java 15.53% JavaScript 0.30% HTML 3.41%
cordova plugin webserver httpd

cordova-httpd's Introduction

CorHttpd: embeded httpd for cordova

Supported platform:

  • iOS
  • Android

You can browse (locally or remotely) to access files in android/ios phone/pad:

  • browse the files in mobile device with a browser in PC.
  • copy files from mobile device to PC quickly, just with Wifi.
  • use cordova webview to access the assets/www/ content with http protocol.

Why http access is good?

  • Use wifi instead of cable, more convenient.
  • For security reason, browser does not support local AJAX calls. It's big bottle neck to deploy HTML5 games to Cordova platform.
  • The most popular phaser.js game engine, a httpd is always required, as it use AJAX to load resource.

How to use CorHttpd?

Add the plugin to your cordova project:

cordova plugin add https://github.com/floatinghotpot/cordova-httpd.git

Quick start, copy the demo files, and just build to play.

cp -r plugins/com.rjfun.cordova.httpd/test/* www/

Javascript APIs

startServer( options, success_callback, error_callback );

stopServer( success_callback, error_callback );

getURL( success_callback, error_callback );

getLocalPath( success_callback, error_callback );

Example code: (read the comments)

    var httpd = null;
    function onDeviceReady() {
        httpd = ( cordova && cordova.plugins && cordova.plugins.CorHttpd ) ? cordova.plugins.CorHttpd : null;
    }
    function updateStatus() {
    	document.getElementById('location').innerHTML = "document.location.href: " + document.location.href;
    	if( httpd ) {
    	  /* use this function to get status of httpd
    	  * if server is up, it will return http://<server's ip>:port/
    	  * if server is down, it will return empty string ""
    	  */
    		httpd.getURL(function(url){
    			if(url.length > 0) {
    				document.getElementById('url').innerHTML = "server is up: <a href='" + url + "' target='_blank'>" + url + "</a>";
    			} else {
    				document.getElementById('url').innerHTML = "server is down.";
    			}
    		});
    		// call this function to retrieve the local path of the www root dir
    		httpd.getLocalPath(function(path){
    			document.getElementById('localpath').innerHTML = "<br/>localPath: " + path;
        	});
    	} else {
    		alert('CorHttpd plugin not available/ready.');
    	}
    }
    function startServer( wwwroot ) {
    	if ( httpd ) {
    	    // before start, check whether its up or not
    	    httpd.getURL(function(url){
    	    	if(url.length > 0) {
    	    		document.getElementById('url').innerHTML = "server is up: <a href='" + url + "' target='_blank'>" + url + "</a>";
	    	    } else {
	    	        /* wwwroot is the root dir of web server, it can be absolute or relative path
	    	        * if a relative path is given, it will be relative to cordova assets/www/ in APK.
	    	        * "", by default, it will point to cordova assets/www/, it's good to use 'htdocs' for 'www/htdocs'
	    	        * if a absolute path is given, it will access file system.
	    	        * "/", set the root dir as the www root, it maybe a security issue, but very powerful to browse all dir
	    	        */
    	    	    httpd.startServer({
    	    	    	'www_root' : wwwroot,
    	    	    	'port' : 8080,
    	    	    	'localhost_only' : false
    	    	    }, function( url ){
    	    	      // if server is up, it will return the url of http://<server ip>:port/
    	    	      // the ip is the active network connection
    	    	      // if no wifi or no cell, "127.0.0.1" will be returned.
        	    		document.getElementById('url').innerHTML = "server is started: <a href='" + url + "' target='_blank'>" + url + "</a>";
    	    	    }, function( error ){
    	    	    	document.getElementById('url').innerHTML = 'failed to start server: ' + error;
    	    	    });
    	    	}
    	    	
    	    });
    	} else {
    		alert('CorHttpd plugin not available/ready.');
    	}
    }
    function stopServer() {
    	if ( httpd ) {
    	    // call this API to stop web server
    	    httpd.stopServer(function(){
    	    	document.getElementById('url').innerHTML = 'server is stopped.';
    	    },function( error ){
    	    	document.getElementById('url').innerHTML = 'failed to stop server' + error;
    	    });
    	} else {
    		alert('CorHttpd plugin not available/ready.');
    	}
    }

Credits

This Cordova plugin is built based on following 2 projects, and thanks to the authors.

  • NanoHTTPD, written in java, for java / android, by psh.
  • CocoaHTTPServer, written in Obj-C, for iOS / Mac OS X, by robbiehanson.

You can use this plugin for FREE. Feel free to fork, improve and send pull request.

If need prompt support, please buy a license, you will be supported with high priority.

More Cordova/PhoneGap plugins by Raymond Xie, find them in plugin registry.

Project outsourcing and consulting service is also available. Please contact us if you have the business needs.

cordova-httpd's People

Contributors

basecode avatar david-christie avatar fidelsomething avatar floatinghotpot avatar ramboz avatar tripodsan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cordova-httpd's Issues

Exception: bind failed: EACCES (Permission denied)

I keep getting this error when trying to call CorHttpd.startServer:
Error in Error callbackId: CorHttpd1894191633 : IO Exception: bind failed: EACCES (Permission denied)
index.html:1 Uncaught (in promise) IO Exception: bind failed: EACCES (Permission denied)

Fails to build on PhoneGap Build with CLI 6

Build something on PhoneGap Build with these lines in your config.xml:

<preference name="phonegap-version" value="cli-6.0.0" />
...
<plugin name="cordova-plugin-httpd" source="npm" />

Build fails with this in the error log:

In file included from /project/wkrenderperf/Plugins/cordova-plugin-httpd/CorHttpd.m:34:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.1.sdk/usr/include/ifaddrs.h:31:1: error: missing '@end'
#include <Availability.h>
^
/project/wkrenderperf/Plugins/cordova-plugin-httpd/CorHttpd.m:32:1: note: implementation started here
@implementation CorHttpd
^
/project/wkrenderperf/Plugins/cordova-plugin-httpd/CorHttpd.m:50:1: error: missing context for method declaration
- (NSString *)getIPAddress:(BOOL)preferIPv4
^
/project/wkrenderperf/Plugins/cordova-plugin-httpd/CorHttpd.m:68:1: error: missing context for method declaration
- (NSDictionary *)getIPAddresses
^
/project/wkrenderperf/Plugins/cordova-plugin-httpd/CorHttpd.m:108:1: error: missing context for method declaration
- (void)pluginInitialize
^
/project/wkrenderperf/Plugins/cordova-plugin-httpd/CorHttpd.m:119:1: error: missing context for method declaration
- (void)startServer:(CDVInvokedUrlCommand*)command
^
/project/wkrenderperf/Plugins/cordova-plugin-httpd/CorHttpd.m:187:1: error: missing context for method declaration
- (void)stopServer:(CDVInvokedUrlCommand*)command
^
/project/wkrenderperf/Plugins/cordova-plugin-httpd/CorHttpd.m:204:1: error: missing context for method declaration
- (void)getURL:(CDVInvokedUrlCommand *)command
^
/project/wkrenderperf/Plugins/cordova-plugin-httpd/CorHttpd.m:211:1: error: missing context for method declaration
- (void)getLocalPath:(CDVInvokedUrlCommand *)command
^
/project/wkrenderperf/Plugins/cordova-plugin-httpd/CorHttpd.m:218:1: error: '@end' must appear in an Objective-C context
@end
^

This prevents us using this plugin to help support WKWebView in Construct 2.

Support for Browser?

Hi,

Is there any planned support for the browser platform? It would make development easier - to test in the browser frequently and then test on an actual device less frequently. Most cordova plugins are offering support for the browser directly, so I think it is worth doing. Is it an easy implementation?

Katie

package org.apache.http.conn.util does not exist

Cordova run failed 😞 with this message:

/home/dev/Desktop/PhoneGap/test/platforms/android/src/com/rjfun/cordova/httpd/CorHttpd.java:15: error: package org.apache.http.conn.util does not exist
import org.apache.http.conn.util.InetAddressUtils;
                                ^
/home/dev/Desktop/PhoneGap/test/platforms/android/src/com/rjfun/cordova/httpd/CorHttpd.java:87: error: cannot find symbol
                        if(InetAddressUtils.isIPv4Address(ip)) {
                           ^
  symbol:   variable InetAddressUtils
  location: class CorHttpd
2 errors

I am using:
OS: Ubuntu 14.04 LTS
Platform: v 6.0
API Level: 23

Please suggest how to fix this error.
Thank you.

File upload

If there is no server side language, how does one use httpd to upload a file to the device? I would love to get some insight!

Background mode

Hi,

The server stops working (is paused) when the app is put in background mode
(switching to another app).

Is it possible to have it running when the app is paused?

Thanks,

Michael

Add support for OSX as target platform

The cordova-osx platform is about to be added as additional supported target platform, mainly for Kiosk-like applications. It would be great to have support for OSX for the httpd server.

Viewing external storage files

Hey
Is there a way to access them securely (authentication) or to access only certain types of files, like only mp3 files?
I require access to only certain types of files.

Approval?

Hi, sorry my question is simple, will Apple and Google accept the app on the store if it includes a webserver?

Have you already submitted any app which is using the plugin?

CorHttpd.getURL - We seem to be missing some stuff

Everytime i try to run my Android Debug Build on Ripple in the Microsoft Visual Studio 2015 with Cordova i encounter this strange error. I have checked with your test files countless times, but can't seem to locate the cause.
I can provide any file useful to track this down, but haven't yet because i didn't want to cram this issue.

unbenannt

Error trying to install the Plugin

Hello trying to install the Plugin I get the following Error.. Any Idead ?

cordova plugin add https://github.com/floatinghotpot/cordova-httpd.git

Error: Failed to fetch plugin https://github.com/floatinghotpot/cordova-httpd.git via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
Error: npm: Command failed with exit code 235 Error output:
npm ERR! addLocal Could not install /var/folders/p_/ffn44cb97ssfrcvsd77yfvdm0000gn/T/npm-38291-f5e7761b/git-cache-54b067fbaa3d1878e91f8c8619307de6/78b9818516842650a9bd59881cbb543db2848d29
npm ERR! Darwin 16.5.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "https://github.com/floatinghotpot/cordova-httpd.git" "--save"
npm ERR! node v5.1.1
npm ERR! npm  v3.3.12
npm ERR! code EISDIR
npm ERR! errno -21
npm ERR! syscall read

npm ERR! eisdir EISDIR: illegal operation on a directory, read
npm ERR! eisdir This is most likely not a problem with npm itself
npm ERR! eisdir and is related to npm not being able to find a package.json in
npm ERR! eisdir a package you are trying to install.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/volkergraf/DEV/NODE/Carfinder/CordovaVectorICL/node_modules/npm-debug.log
Volkers-MBP-9:CordovaVectorICL volkergraf$ cordova plugin add https://github.com/floatinghotpot/cordova-httpd.git
Error: Failed to fetch plugin https://github.com/floatinghotpot/cordova-httpd.git via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
Error: npm: Command failed with exit code 235 Error output:
npm ERR! addLocal Could not install /var/folders/p_/ffn44cb97ssfrcvsd77yfvdm0000gn/T/npm-38303-1d8813f4/git-cache-fe474ec1ebeb758300f6b78ad25f59ca/78b9818516842650a9bd59881cbb543db2848d29
npm ERR! Darwin 16.5.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "https://github.com/floatinghotpot/cordova-httpd.git" "--save"
npm ERR! node v5.1.1
npm ERR! npm  v3.3.12
npm ERR! code EISDIR
npm ERR! errno -21
npm ERR! syscall read

npm ERR! eisdir EISDIR: illegal operation on a directory, read
npm ERR! eisdir This is most likely not a problem with npm itself
npm ERR! eisdir and is related to npm not being able to find a package.json in
npm ERR! eisdir a package you are trying to install.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/volkergraf/DEV/NODE/Carfinder/CordovaVectorICL/node_modules/npm-debug.log


Break SVG loading

I use img tags with svg link inside <img src="relative/path/to/myImage.svg"/> and the link is good (http://localhost:8080/path/to/myimage.svg), but they are not displayed..

Looking in the Network tab, the image respond with 200 Status code, and I don't know where this problem can come from...

I've tried a lot of CSP configs, but no one seems to work..

Phonegap build

Hi is there any chance to publish this plugin to phonegap build?

Server stops on iOS after sleep

I'm noticing that a service started works fine to begin with.

However after the device sleeps for a period of time, it seems as if the server gets shut down, or stops responding to requests.

Any help would be greatly appreciated.

https

Hello,

Is it possible to start a https server with the plugin? Both implementations used seem to support it, but I can't see it being exposed.

Thanks!

Dynamic behavior

This server so far is only static.

That may suite well for most cases, but I wanted to add some Javascript-defined dynamic behavior. This allows for more interaction.

I did this for Android only, because at the moment I don't need it for iOS. I will make a PR from my fork

HTML file displays as plain text on iOS

On iOS (works on Android), HTML files are displayed as plain text when browsing (see attached screenshot and html file)

I can't attach the file here, but I can tell you that the file is encoded in UTF8 with BOM.

screenshot

`localhost_only: true` is not calling the `success()` callback

Hi,

I am starting the server with below code.

httpd.getURL(function(url) {
  var config = {
    www_root: '',
    port: 8080,
    localhost_only: true
  };

  function successStartingServer(url) {
    console.log('Server started with url: '+url);
  }

  if(!url.length) {
    httpd.startServer(config, successStartingServer, errorStartServer);
  }
});

I find that function successStartingServer() is never called. When I set localhost_only to false, everything works as expected.

Am I doing something wrong here?

Feature if possible

Hi, i know that this plugin is working as intended, is there any change you can implement to make this work like a network comunication pipe?
for exp: you type in the remote browser http://ip.off.device:8080/some/route/ and have on the app a listener for requests on the started server:

var httpd = ( cordova && cordova.plugins && cordova.plugins.CorHttpd ) ? cordova.plugins.CorHttpd : null;

httpd.on('request', function(uri){
  console.log(uri);// /some/route/
});

My intention is to have an application running on a device and remotely (on the same network) do some actions via browser for exp serve some html, js, css files, when the user clicks some button it makes a new request that will be handled by the server. This plugin is the closest i found to what i want using phonegap, i could achieve this using some RTC framework like firebase, but i think that having a local network server will be faster.

wp8 support?

Any information if there will be wp8 support?
So to be able use phaser

Nano HTTPD Server crashes in case of an empty request

Nano HTTPD Server crashes in case of an empty request (where a connection is made but the input stream read return -1 for no bytes). In this case the method is not populated resulting in a Nullpointerexception. This situation happens sometimes in a range request from Android VideoView in Kitkat 4.4.2.

Cordova not available

the example code from the site leaves my browser saying "Run time Error" and in the browser console its telling me cordova is not available. How can i fix?

send and receive

hello is there a way to send and receive text data from mobile server and the client? thanks

localhost only

My reason for looking into this project is a series of javascripts which will not run unless called from a server (such as cordovajs). I don't particularly need or want anyone outside the device to access the files.

Is it possible to restrict this service to localhost on the device?

Feature request: enable Access-Control-Allow-Origin

This plugin is potentially very useful for working with WKWebView on iOS. However it is missing one feature to help with this a lot: setting Access-Control-Allow-Origin.

In C2 we are using a model where the index.html file and images are loaded as local files, but audio and video are served over HTTP. This brings the best combination of a) a predictable origin for storage to work and b) serving files that are otherwise impossible to get to work in WKWebView. However the local index.html file and a video on 127.0.0.1:49876 count as coming from different origins, therefore some restrictions are put in place, e.g. the video cannot be uploaded as a WebGL texture.

If the preview server is able to serve the following header:

Access-Control-Allow-Origin: *

or, for better security, specifically identifying the preview server itself only:

Access-Control-Allow-Origin: http://127.0.0.1:49876

This should then lift the cross-origin restrictions and allow everything to work optimally in WKWebView.

We can probably work around this for the time being, but this would make it a lot easier to use!

Removing CocoaLumberJack code and adding dependency

Any chance of removing the CocoaLumberJack code in vendors and add a dependency to the cordova-plugin-cocoalumberjack plugin in plugin.xml ?

 <platform name="ios">
    <dependency id="cordova-plugin-cocoalumberjack" version="~0.0.4" />

...

It will simplify the code and make it compatible with other plugins

Cordova app end every time after a few clicks in the server

Hi,

Great plugin !

I tested to build just simple demo app using your example code for starting a web server.
Works great but just two problems. I set the www root to: /
storage/emulated/0/DCIM/Camera/

First problem the server shows only a fews pics. The newest ones. Works great, but
the second problem is: The apps quits after a few clicks.

Maybe I made something wrong.

I tested this on a Huawei Mate 7 with Android 4.4.2

One thing I am using Meteor to create my cordova apps.

IO Exception: bind failed: EADDRINUSE

I keep getting this error
IO Exception: bind failed: EADDRINUSE (Address already in use)
when trying to call CorHttpd.startServer

I've even tried calling CorHttpd.stopServer numerous times before calling CorHttpd.startServer again.

I also notice that in the console the address my images are getting retrived from is:
http://192.168.99.17:8285/img_src-7e09c9d3e96378bf549fc283fd6e1e5b7014cc3372.jpg and my url from the start server callback is http://127.0.0.1:8447/

Remote request

Hey
Is it possible to use this server as a middle ware to communicate with a Raspberry Pi server in the same network?

Sending a XmlHttpRequest directly from cordova app to a server in Pi is not possible, reason being it becomes a preflight request. And the server in Pi does not support cors.

So I was thinking to use this library to act as a gateway between the mobile app and the Pi. But I am not clear on the workflow? How do you run it that way.
Like if I have this XHR request

var xmlHTTP = new XMLHttpRequest();
xmlHTTP.onreadystatechange = function() {
  if(xmlHTTP.readyState === xmlHTTP.DONE) {
    if(xmlHTTP.status === 200) {
        console.log(xmlHTTP.responseText)
    } else {
        console.log("not OK: " + xmlHTTP.status)
    }
  }
};
xmlHTTP.open('POST', 'http://192.168.1.6:49152/ctl/RenderingControl', true);
xmlHTTP.setRequestHeader("SOAPAction", "urn:schemas-upnp-org:service:RenderingControl:1#GetVolume");
xmlHTTP.setRequestHeader( "Content-Type","text/xml; charset=utf-8");

// build SOAP request
var sr = '<?xml version="1.0"?>'+
'<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">'+
' <s:Body>'+
  '<u:GetVolume xmlns:u="urn:schemas-upnp-org:service:RenderingControl:1">'+
   '<InstanceID>0</InstanceID>'+
   '<Channel>Master</Channel>'+
  '</u:GetVolume>'+
 '</s:Body>'+
'</s:Envelope>';

xmlHTTP.send(sr);

How do you communicate now with this server and ask the server to pass on the post request to Pi?

[Android] Sometimes it gets the wrong IP address on multi-interface devices

Hi,

trying my app on a tablet and on a Sony Bravia Android TV, I've got different results for IP addresses.

In particular, I was getting a different IP string than the one corresponding to the active WiFi IP address. That's perhaps due to the fact that the TV has more than 1 IP interfaces, and that the __getLocalIpAddress() Java Method just stops at the first it mets. So I was visualizing a different address than the one I was actually using.

I tried a different approach using Android WifiManager and it seems better, even though it could fail when the device is only ethernet connected or without WiFi.

    private String __getWifiIpAddress(){
        WifiManager wifiMgr = (WifiManager) cordova.getActivity().getSystemService(cordova.getActivity().WIFI_SERVICE);
        WifiInfo wifiInfo = wifiMgr.getConnectionInfo();
        int ip = wifiInfo.getIpAddress();
        @SuppressWarnings("deprecation")
        String ipAddress = Formatter.formatIpAddress(ip);
        return ipAddress;
    }

This has solved my problem and could be a starting point to get the IP address more reliably.

Works great in android, not so much in ios 9...

I am using this plugin to allow me to load up downloaded kml files in an android app and it is working great. I am now porting over into ios 9 and I am having issues getting it to work the same way. I am downloading the kml files to the Library/NoCloud/files folder and I can see them on the ipad, but I cannot pull them into a layer for my leaflet map.

Maybe a permissions issue? I am puzzled...

Reports ip of 0.0.0.0 when iOS in Airplane Mode

Using WKWebView on iOS 9.2.1, if Airplane Mode is turned on, httpd.startServer() success callback passes an ip of "0.0.0.0" to the function, even though it's actually running on 127.0.0.1.

So to use it right now, I'm doing something like this:

httpd.startServer({
    'www_root': wwwroot,
    'port': 8080
}, function (url) {
    url = url.replace("0.0.0.0", "127.0.0.1"); // Airplane mode correction
    console.log("server is started: " + url);
}

Falls and does not release ip address

Falls with exception
Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equalsIgnoreCase(java.lang.String)' on a null object reference
at com.rjfun.cordova.httpd.NanoHTTPD$HTTPSession.run(NanoHTTPD.java:430)
at java.lang.Thread.run(Thread.java:818)

If we go back to the app, then up server can no longer, because the ip address is busy (IO Exception: bind failed: EADDRINUSE)

Unable to build iOS (No such file or directory)

Hi all,
i have a problem when i execute cordova build ios after the plugin installation:

...
ug-iphonesimulator/testprj.build/Objects-normal/i386/HTTPServer-C5089DC9E665659.o
clang: error: no such file or directory: '/Users/bms/Development/phonegap/testprj/platforms/ios/testprj/Plugins/com.rjfun.cordova.httpd/HTTPServer.m'
clang: error: no input files
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 1

2014-09-18 10:34:47.618 xcodebuild[66847:5317]  DVTAssertions: Warning in /SourceCache/IDEXcode3ProjectSupport/IDEXcode3ProjectSupport-5069/Xcode3Core/LegacyProjects/Frameworks/DevToolsCore/DevToolsCore/SpecificationTypes/BuiltInSpecifications/Compilers/XCGccMakefileDependencies.m:76
Details:  Failed to load dependencies output contents from ``/Users/bms/Development/phonegap/testprj/platforms/ios/build/testprj.build/Debug-iphonesimulator/testprj.build/Objects-normal/i386/CorHttpd.d''. Error: Error Domain=NSCocoaErrorDomain Code=260 "The file “CorHttpd.d” couldn’t be opened because there is no such file." UserInfo=0x7f92e57c9b50 {NSFilePath=/Users/bms/Development/phonegap/testprj/platforms/ios/build/testprj.build/Debug-iphonesimulator/testprj.build/Objects-normal/i386/CorHttpd.d, NSUnderlyingError=0x7f92e57cef50 "The operation couldn’t be completed. No such file or directory"}. User info: {
    NSFilePath = "/Users/bms/Development/phonegap/testprj/platforms/ios/build/testprj.build/Debug-iphonesimulator/testprj.build/Objects-normal/i386/CorHttpd.d";
    NSUnderlyingError = "Error Domain=NSPOSIXErrorDomain Code=2 \"The operation couldn\U2019t be completed. No such file or directory\"";
}.
Function: void XCGccMakefileDependenciesParsePathsFromRuleFile(NSString *__strong, void (^__strong)(NSString *__strong))
Thread:   <NSThread: 0x7f92e57ee290>{name = (null), num = 7}
Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide.
2014-09-18 10:34:47.622 xcodebuild[66847:3e03]  DVTAssertions: Warning in /SourceCache/IDEXcode3ProjectSupport/IDEXcode3ProjectSupport-5069/Xcode3Core/LegacyProjects/Frameworks/DevToolsCore/DevToolsCore/SpecificationTypes/BuiltInSpecifications/Compilers/XCGccMakefileDependencies.m:76
Details:  Failed to load dependencies output contents from ``/Users/bms/Development/phonegap/testprj/platforms/ios/build/testprj.build/Debug-iphonesimulator/testprj.build/Objects-normal/i386/HTTPServer-C5089DC9E665659.d''. Error: Error Domain=NSCocoaErrorDomain Code=260 "The file “HTTPServer-C5089DC9E665659.d” couldn’t be opened because there is no such file." UserInfo=0x7f92e57803e0 {NSFilePath=/Users/bms/Development/phonegap/testprj/platforms/ios/build/testprj.build/Debug-iphonesimulator/testprj.build/Objects-normal/i386/HTTPServer-C5089DC9E665659.d, NSUnderlyingError=0x7f92e57ce050 "The operation couldn’t be completed. No such file or directory"}. User info: {
    NSFilePath = "/Users/bms/Development/phonegap/testprj/platforms/ios/build/testprj.build/Debug-iphonesimulator/testprj.build/Objects-normal/i386/HTTPServer-C5089DC9E665659.d";
    NSUnderlyingError = "Error Domain=NSPOSIXErrorDomain Code=2 \"The operation couldn\U2019t be completed. No such file or directory\"";
}.
Function: void XCGccMakefileDependenciesParsePathsFromRuleFile(NSString *__strong, void (^__strong)(NSString *__strong))
Thread:   <NSThread: 0x7f92e5780420>{name = (null), num = 6}
Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide.
** BUILD FAILED **


The following build commands failed:
    CompileC build/testprj.build/Debug-iphonesimulator/testprj.build/Objects-normal/i386/CorHttpd.o testprj/Plugins/com.rjfun.cordova.httpd/CorHttpd.m normal i386 objective-c com.apple.compilers.llvm.clang.1_0.compiler
    CompileC build/testprj.build/Debug-iphonesimulator/testprj.build/Objects-normal/i386/HTTPServer-C5089DC9E665659.o testprj/Plugins/com.rjfun.cordova.httpd/HTTPServer.m normal i386 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(2 failures)
Error: /Users/bms/Development/phonegap/testprj/platforms/ios/cordova/build: Command failed with exit code 65
    at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:135:23)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:753:16)
    at Process.ChildProcess._handle.onexit (child_process.js:820:5)

Steps to reproduce the issue:

cordova create testprj it.company.testprj testprj
cd testprj/
cordova platform add ios
cordova build ios
cordova plugin add https://github.com/floatinghotpot/cordova-httpd.git
cordova build ios

Where am I wrong?
Thank you!

** BUILD FAILED **

On "cordova build ios" (deployment-target = 8.0) I always get an error with exit code 65, if I include the plugin.

The build command logs serveral errors ´ deprecation warnings. e.q.

com.rjfun.cordova.httpd/DDTTYLogger.m:688:83: warning: implicit conversion from enumeration type 'enum CGImageAlphaInfo' to different enumeration type 'CGBitmapInfo' (aka 'enum CGBitmapInfo') [-Wenum-conversion]
CGContextRef context = CGBitmapContextCreate(&pixel, 1, 1, 8, 4, rgbColorSpace, kCGImageAlphaNoneSkipLast);
~~~~~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.

Am I doing something from or is this plugin not just working with ios 8+ yet?

Thank you in advance!

XCode Compiler warnings

My XCode ist throwing a ton of warnings (e.g. warning: no rule to process file '/Users/jensfischer/workspaceCordova/theorietrainer-app/platforms/ios/WinDriveTheorieTrainer-WebApp/Plugins/com.rjfun.cordova.httpd/HTTPServer.h).
This happens, because the header files are included in the compile build phase.
I think the problem could be solved, if the header and source files are correctly described in the plugin.xml. At the moment all files (header and implementation .h/.m) are marked as source-file.
Header files have to be added as header-file.

API like Node's http.createServer?

Is it possible to handle requests and responses with cordova-httpd, similar to how Node's http.createServer command works? It would be sooo great if this project could do that.

Possible feature?

I wonder if it would be possible to get the component to serve from more than one location? As in try to serve from location A and if the file is not found then serve from location B?

A and B would have to be root directories that had the path appended to them.

If this could be added I'd be very happy to buy a premium license (before you do the work!)

cordova-plugin-httpd breaks iOS build

I'm having an issue with cordova-plugin-httpd on iOS which seems to be easily reproducible with the following steps:

cordova create com.cordova.test
cordova add platform ios
cordova plugin add cordova-plugin-console
cordova build ios

Everything OK, app builds and runs with the usual "ready" logo flashing.

`
cordova plugin add cordova-plugin-httpd

cordova build ios
`

Build fails with the following:

** BUILD FAILED **

The following build commands failed:
CompileC build/HelloCordova.build/Debug-iphonesimulator/HelloCordova.build/Objects-normal/i386/CorHttpd.o HelloCordova/Plugins/cordova-plugin-httpd/CorHttpd.m normal i386 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
ERROR building one of the platforms: Error code 65 for command: xcodebuild with args: -xcconfig,/Users/paul/git/test/test/cordova_test/com.cordova.test/platforms/ios/cordova/build-debug.xcconfig,-project,HelloCordova.xcodeproj,ARCHS=i386,-target,HelloCordova,-configuration,Debug,-sdk,iphonesimulator,build,VALID_ARCHS=i386,CONFIGURATION_BUILD_DIR=/Users/paul/git/test/test/cordova_test/com.cordova.test/platforms/ios/build/emulator,SHARED_PRECOMPS_DIR=/Users/paul/git/test/test/cordova_test/com.cordova.test/platforms/ios/build/sharedpch
You may not have the required environment or OS to build this project
Error: Error code 65 for command: xcodebuild with args: -xcconfig,/Users/paul/git/test/test/cordova_test/com.cordova.test/platforms/ios/cordova/build-debug.xcconfig,-project,HelloCordova.xcodeproj,ARCHS=i386,-target,HelloCordova,-configuration,Debug,-sdk,iphonesimulator,build,VALID_ARCHS=i386,CONFIGURATION_BUILD_DIR=/Users/paul/git/test/test/cordova_test/com.cordova.test/platforms/ios/build/emulator,SHARED_PRECOMPS_DIR=/Users/paul/git/test/test/cordova_test/com.cordova.test/platforms/ios/build/sharedpch

cordova plugin rm cordova-plugin-httpd
cordova build ios

Build succeeds again.

I'm using I think latest XCode, iOS, and Cordova.

cordova -v
6.0.0

cordova plugin list
cordova-plugin-console 1.0.2 "Console"
cordova-plugin-httpd 0.9.2 "CorHttpd"
cordova-plugin-whitelist 1.2.1 "Whitelist"

XCode Version 7.2.1 (7C1002)

I initially developed an app using rjfun plugin, and it ran successfully, but have issues now with new plugin name for a new project. Is there some configuration issue?

Thanks, Paul

Plugin does not compile with [email protected]

testing with [email protected] results:

cordova/platforms/android/src/com/rjfun/cordova/httpd/CorHttpd.java:15: error: package org.apache.http.conn.util does not exist
import org.apache.http.conn.util.InetAddressUtils;
                                ^
/Users/tripod/codez/screens/master/modules/screens-player/cordova/build/android/target/cordova/platforms/android/src/com/rjfun/cordova/httpd/CorHttpd.java:87: error: cannot find symbol
                        if(InetAddressUtils.isIPv4Address(ip)) {
                           ^
  symbol:   variable InetAddressUtils
  location: class CorHttpd

IO Exception: Host is unresolved: 127.0.0.1"

Everything's working fine on iOS so far but on Android I get IO Exception: Host is unresolved: 127.0.0.1 in the error callback when calling httpd.startServer

Am I doing something stupid?

PHP Addition

Is there a way to have CorHTTPd to handle PHP requests?

Installation Error: Cannot read property 'indexOf' of undefined

Hi,

I am getting the error below when trying to install the plugin in my ionic project.

TypeError: Cannot read property 'indexOf' of undefined
at /home/xxxxx/.npm-packages/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/install.js:244:44
at Array.forEach (native)
at getEngines (/home/xxxxx/.npm-packages/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/install.js:223:13)
at runInstall (/home/xxxxx/.npm-packages/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/install.js:285:22)
at /home/xxxxx/.npm-packages/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/install.js:84:16
at _fulfilled (/home/xxxxx/.npm-packages/lib/node_modules/cordova/node_modules/q/q.js:787:54)
at self.promiseDispatch.done (/home/xxxxx/.npm-packages/lib/node_modules/cordova/node_modules/q/q.js:816:30)
at Promise.promise.promiseDispatch (/home/xxxxx/.npm-packages/lib/node_modules/cordova/node_modules/q/q.js:749:13)
at /home/xxxxx/.npm-packages/lib/node_modules/cordova/node_modules/q/q.js:810:14
at flush (/home/xxxxx/.npm-packages/lib/node_modules/cordova/node_modules/q/q.js:108:17)

The command I ran was:

cordova plugin add https://github.com/floatinghotpot/cordova-httpd.git

My environment is as follows:

Cordova CLI: 5.2.0
Gulp version: CLI version 3.9.0
Gulp local: Local version 3.9.1
Ionic Framework Version: 1.1.1
Ionic CLI Version: 1.7.16
Ionic App Lib Version: 0.7.3
OS: Distributor ID: Ubuntu Description: Ubuntu 14.04.4 LTS
Node Version: v0.12.7

I have had a look and it seems to fail on the following line in plugman:

/src/plugman/install.js:244:44 -> platformIndex = engine.platform.indexOf(platform);

I am not entirely sure why this is.

I have added the android platform to my project:

Installed platforms: android 4.1.1

I have used this plugin in the past and I am not sure why this is currently occuring.

Perhaps you could assist.

Regards

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.