mattstevens / routinghttpserver Goto Github PK
View Code? Open in Web Editor NEWA routing API for CocoaHTTPServer
License: MIT License
A routing API for CocoaHTTPServer
License: MIT License
I encountered a crash (just once) when the local device disappeared from the network in the middle of responding to a request:
#0 0x00007fff909760dd in objc_msgSend ()
#1 0x0000000108f42223 in -[RoutingConnection setHeadersForResponse:isError:] at /Users/ndouglas/Projects/DEVONthink-Sync-Plugin-2/Sync/External/RoutingHTTPServer/Source/RoutingConnection.m:91
#2 0x0000000108f42758 in -[RoutingConnection preprocessResponse:] at /Users/ndouglas/Projects/DEVONthink-Sync-Plugin-2/Sync/External/RoutingHTTPServer/Source/RoutingConnection.m:110
#3 0x0000000108e97039 in -[HTTPConnection sendResponseHeadersAndBody] at /Users/ndouglas/Projects/DEVONthink-Sync-Plugin-2/Sync/External/RoutingHTTPServer/External/CocoaHTTPServer/Core/HTTPConnection.m:1243
#4 0x0000000108e95f87 in -[HTTPConnection replyToHTTPRequest] at /Users/ndouglas/Projects/DEVONthink-Sync-Plugin-2/Sync/External/RoutingHTTPServer/External/CocoaHTTPServer/Core/HTTPConnection.m:1025
#5 0x0000000108e9b62a in -[HTTPConnection socket:didReadData:withTag:] at /Users/ndouglas/Projects/DEVONthink-Sync-Plugin-2/Sync/External/RoutingHTTPServer/External/CocoaHTTPServer/Core/HTTPConnection.m:2199
#6 0x0000000108f3b553 in __37-[GCDAsyncSocket completeCurrentRead]_block_invoke at /Users/ndouglas/Projects/DEVONthink-Sync-Plugin-2/Sync/External/RoutingHTTPServer/External/CocoaHTTPServer/Vendor/CocoaAsyncSocket/GCDAsyncSocket.m:5039
#7 0x00000001008412bb in _dispatch_call_block_and_release ()
#8 0x000000010083bd43 in _dispatch_client_callout ()
#9 0x000000010083ffb3 in _dispatch_queue_drain ()
#10 0x0000000100841fc0 in _dispatch_queue_invoke ()
#11 0x000000010083ef5e in _dispatch_root_queue_drain ()
#12 0x0000000100850cd0 in _dispatch_worker_thread3 ()
#13 0x00007fff89d296cb in _pthread_wqthread ()
#14 0x00007fff89d274a1 in start_wqthread ()
Enqueued from GCDAsyncSocket (Thread 368)Queue : GCDAsyncSocket (serial)
#0 0x000000010083dc92 in _dispatch_barrier_async_f_slow ()
#1 0x0000000108f3b41e in -[GCDAsyncSocket completeCurrentRead] at /Users/ndouglas/Projects/DEVONthink-Sync-Plugin-2/Sync/External/RoutingHTTPServer/External/CocoaHTTPServer/Vendor/CocoaAsyncSocket/GCDAsyncSocket.m:5037
#2 0x0000000108f3a3bb in -[GCDAsyncSocket doReadData] at /Users/ndouglas/Projects/DEVONthink-Sync-Plugin-2/Sync/External/RoutingHTTPServer/External/CocoaHTTPServer/Vendor/CocoaAsyncSocket/GCDAsyncSocket.m:4812
#3 0x0000000108f38736 in -[GCDAsyncSocket maybeDequeueRead] at /Users/ndouglas/Projects/DEVONthink-Sync-Plugin-2/Sync/External/RoutingHTTPServer/External/CocoaHTTPServer/Vendor/CocoaAsyncSocket/GCDAsyncSocket.m:4002
#4 0x0000000108f37e49 in __79-[GCDAsyncSocket readDataToData:withTimeout:buffer:bufferOffset:maxLength:tag:]_block_invoke at /Users/ndouglas/Projects/DEVONthink-Sync-Plugin-2/Sync/External/RoutingHTTPServer/External/CocoaHTTPServer/Vendor/CocoaAsyncSocket/GCDAsyncSocket.m:3907
#5 0x00000001008412bb in _dispatch_call_block_and_release ()
#6 0x000000010083bd43 in _dispatch_client_callout ()
#7 0x000000010083ffb3 in _dispatch_queue_drain ()
#8 0x0000000100841fc0 in _dispatch_queue_invoke ()
#9 0x000000010083ef5e in _dispatch_root_queue_drain ()
#10 0x0000000100850cd0 in _dispatch_worker_thread3 ()
#11 0x00007fff89d296cb in _pthread_wqthread ()
#12 0x00007fff89d274a1 in start_wqthread ()
Relevant method:
- (void)setHeadersForResponse:(HTTPMessage *)response isError:(BOOL)isError {
[http.defaultHeaders enumerateKeysAndObjectsUsingBlock:^(id field, id value, BOOL *stop) {
[response setHeaderField:field value:value];
}];
....
}
Limited messing around in the debugger:
(lldb) po http.defaultHeaders
error: Execution was interrupted, reason: EXC_BAD_ACCESS (code=EXC_I386_GPFLT).
The process has been returned to the state before expression evaluation.
(lldb) po http
0x0000600000194500
It's entirely possible that it's something that I'm doing, i.e. shutting off the server too abruptly or something, so feel free to assume I'm a dangerous idiot :-).
I can show you any relevant code you'd like to see.
I'd like handleMethod:withPath:block: to be able to defer response until after some other asynchronous action has completed.
For example:
handleMethod is called, I pull data from Core Data asynchronously, and finally respond to the HTTP request with respondWithString: (or other).
The problem is that the connection is immediately closed after the end of the block call in handleMethod:withPath:block:. I kind of just assumed it would be possible to do what I was thinking based on the method names and the use of blocks. Is it possible to add an asynchronous group of responses that hold the connection open until I mark done?
Hello,
Could I change the name of the default localhost by http://example.com/
For example:
Instead of
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://localhost:1234"]];
I want to do
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http:///example.com/"]];
Thanks in advance.
Is it possible to have a long-lived connection using a text/event-stream content type (akin to http://tenderlovemaking.com/2012/07/30/is-it-live.html)? I've had a look around the source but can't see anything obvious.
The CocoaHTTPServer project is no longer maintained at code.google.com but was moved to GitHub.
Would you be so kind to update the submodule URL to https://github.com/robbiehanson/CocoaHTTPServer.git ?
Thanks a million.
Recently I'm working on a project to server music from iPhone's library to DLNA supported device. Doing some search I came to your project. I'm wondering if you have implemented DLNA server with this project?
Sorry for my poor English.
RoutingHTTPServer seems quite promising and it has already helped me alot. Thanks for sharing it.
Question: How do i upload file using RoutingHTTPServer. can you please include an example for it.
After i run a simple example code using swift. I can not connect the embedded server. Does it work well for swift?
In RoutingConnection, the line :
@Property (atomic, weak) RoutingHTTPServer *http;
produces this error :
"cannot synthesize weak property because the current deployment target does not support weak reference"
Any idea how to fix this please ? I've searched on Google but I could not find how to solve this issue.
When setting Deployment Target to 10.6 and running resulting RoutingHttpServer example on a 10.6 machine, the following error appears in the system.log:
RoutingHTTPServer[378]: *** -[NSPlaceholderMutableString initWithString:]: nil argument
It looks like it's coming from around the:
path = [regex stringByReplacingMatchesInString:
section of RoutingHttpServer:routeWithPath. That API doesn't exist in 10.6 I think.
Compiling on OS X 10.8 or iOS 6 will fail:
error: 'release' is unavailable: not available in automatic reference counting mode
dispatch_release
must not be used on OS X >=10.8 and iOS 6
see this discussion for further information:
http://stackoverflow.com/questions/8618632/does-arc-support-dispatch-queues
It would be cool if you could add support for Carthage.
https://github.com/Carthage/Carthage#supporting-carthage-for-your-framework
Automatically parse parameters from HTML forms into the params dictionary.
Congraduations! Apple is using this project in OS X Server app.
http://www.opensource.apple.com/source/HTTPServer/HTTPServer-11/
I am personally using it for NetworkObjects
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.