00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #include "nsIServerSocket.idl"
00040 #include "nsIPropertyBag.idl"
00041
00042 interface nsILocalFile;
00043 interface nsISimpleEnumerator;
00044 interface nsIOutputStream;
00045
00046 interface nsIHttpServer;
00047 interface nsIHttpRequestHandler;
00048 interface nsIHttpRequestMetadata;
00049 interface nsIHttpResponse;
00050
00055 [scriptable, uuid(5520f79e-ecd5-4c40-843b-97ee13a23747)]
00056 interface nsIHttpServer : nsIServerSocketListener
00057 {
00068 void start(in long port);
00069
00081 void stop();
00082
00094 void registerFile(in string path, in nsILocalFile file);
00095
00112 void registerPathHandler(in string path, in nsIHttpRequestHandler handler);
00113
00131 void registerErrorHandler(in unsigned long code, in nsIHttpRequestHandler handler);
00132
00150 void registerDirectory(in string path, in nsILocalFile dir);
00151
00165 void setIndexHandler(in nsIHttpRequestHandler handler);
00166 };
00167
00182 [scriptable, function, uuid(2bbb4db7-d285-42b3-a3ce-142b8cc7e139)]
00183 interface nsIHttpRequestHandler : nsISupports
00184 {
00199 void handle(in nsIHttpRequestMetadata metadata, in nsIHttpResponse response);
00200 };
00201
00202
00207 [scriptable, uuid(3a899b17-b6eb-4333-8ef4-912df454a551)]
00208 interface nsIHttpRequestMetadata : nsIPropertyBag
00209 {
00213 readonly attribute string method;
00214
00220 readonly attribute string host;
00221
00225 readonly attribute unsigned long port;
00226
00231 readonly attribute string path;
00232
00237 readonly attribute string queryString;
00238
00245 readonly attribute string httpVersion;
00246
00264 string getHeader(in string fieldName);
00265
00277 boolean hasHeader(in string fieldName);
00278
00284 readonly attribute nsISimpleEnumerator headers;
00285
00286
00287 };
00288
00289
00294 [scriptable, uuid(a2aaaff7-03bd-43b6-b460-94671e288093)]
00295 interface nsIHttpResponse : nsISupports
00296 {
00314 void setStatusLine(in string httpVersion,
00315 in unsigned short statusCode,
00316 in string description);
00317
00335 void setHeader(in string name, in string value, in boolean merge);
00336
00341 readonly attribute nsIOutputStream bodyOutputStream;
00342
00349 void write(in string data);
00350 };