Changeset 22472 in osm for applications
- Timestamp:
- 2010-07-28T22:23:53+02:00 (14 years ago)
- Location:
- applications/editors/josm/plugins/remotecontrol
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/remotecontrol/.project
r9417 r22472 4 4 <comment></comment> 5 5 <projects> 6 <project>JOSM</project> 6 7 </projects> 7 8 <buildSpec> -
applications/editors/josm/plugins/remotecontrol/CONTRIBUTION
r9417 r22472 1 1 Originally developed by Frederik Ramm <frederik@remote.org>. Add yourself 2 2 if you contribute. 3 4 Stephan Knauss <osm@stephans-server.de>: 5 added /version command to return protocol version 6 added CORS headers for modern browsers, legacy browsers can use jsonp -
applications/editors/josm/plugins/remotecontrol/build.xml
r21706 r22472 28 28 29 29 <!-- set before publising --> 30 <property name="commit.message" value=" Changed the constructor signature of the plugin main class" />30 <property name="commit.message" value="Added version info capable of jsonp. Also made header CORS aware" /> 31 31 <property name="plugin.main.version" value="2830" /> 32 32 -
applications/editors/josm/plugins/remotecontrol/src/org/openstreetmap/josm/plugins/remotecontrol/RequestProcessor.java
r21433 r22472 43 43 public class RequestProcessor extends Thread 44 44 { 45 /** 46 * RemoteControl protocol version. 47 * Change minor number for compatible interface extensions. Change major number in case of incompatible changes. 48 */ 49 public static final String PROTOCOLVERSION = "{\"protocolversion\": {\"major\": 1, \"minor\": 0}, \"application\": \"JOSM RemoteControl\"}"; 50 51 45 52 /** The socket this processor listens on */ 46 53 private Socket request; … … 80 87 try 81 88 { 89 String content = "OK\r\n"; 90 String contentType = "text/plain"; 91 82 92 OutputStream raw = new BufferedOutputStream( request.getOutputStream()); 83 93 out = new OutputStreamWriter(raw); … … 278 288 } 279 289 // TODO: select/zoom to downloaded 280 } 281 sendHeader(out, "200 OK", "text/plain", false); 282 out.write("Content-length: 4\r\n"); 290 } else if (command.equals("/version")) { 291 content = RequestProcessor.PROTOCOLVERSION; 292 contentType = "application/json"; 293 if (args.containsKey("jsonp")) { 294 content = args.get("jsonp")+ " && " + args.get("jsonp") + "(" + content + ")"; 295 } 296 } 297 sendHeader(out, "200 OK", contentType, false); 298 out.write("Content-length: "+content.length()+"\r\n"); 283 299 out.write("\r\n"); 284 out.write( "OK\r\n");300 out.write(content); 285 301 out.flush(); 286 302 } … … 409 425 out.write("Server: JOSM RemoteControl\r\n"); 410 426 out.write("Content-type: " + contentType + "\r\n"); 427 out.write("Access-Control-Allow-Origin: *\r\n"); 411 428 if (endHeaders) 412 429 out.write("\r\n");
Note:
See TracChangeset
for help on using the changeset viewer.