server.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. Copyright (c) 2003-2006 by Juliusz Chroboczek
  3. Permission is hereby granted, free of charge, to any person obtaining a copy
  4. of this software and associated documentation files (the "Software"), to deal
  5. in the Software without restriction, including without limitation the rights
  6. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. copies of the Software, and to permit persons to whom the Software is
  8. furnished to do so, subject to the following conditions:
  9. The above copyright notice and this permission notice shall be included in
  10. all copies or substantial portions of the Software.
  11. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  17. THE SOFTWARE.
  18. */
  19. extern int serverExpireTime, dontCacheRedirects;
  20. typedef struct _HTTPServer {
  21. char *name;
  22. int port;
  23. int addrindex;
  24. int isProxy;
  25. int version;
  26. int persistent;
  27. int pipeline;
  28. int lies;
  29. int rtt;
  30. int rate;
  31. time_t time;
  32. int numslots;
  33. int maxslots;
  34. HTTPConnectionPtr *connection;
  35. FdEventHandlerPtr *idleHandler;
  36. HTTPRequestPtr request, request_last;
  37. struct _HTTPServer *next;
  38. } HTTPServerRec, *HTTPServerPtr;
  39. extern AtomPtr parentHost;
  40. extern int parentPort;
  41. void preinitServer(void);
  42. void initServer(void);
  43. void httpServerAbortHandler(ObjectPtr object);
  44. int httpMakeServerRequest(char *name, int port, ObjectPtr object,
  45. int method, int from, int to,
  46. HTTPRequestPtr requestor);
  47. int httpServerQueueRequest(HTTPServerPtr server, HTTPRequestPtr request);
  48. int httpServerTrigger(HTTPServerPtr server);
  49. int httpServerSideRequest(HTTPServerPtr server);
  50. int httpServerDoSide(HTTPConnectionPtr connection);
  51. int httpServerSideHandler(int status,
  52. FdEventHandlerPtr event,
  53. StreamRequestPtr srequest);
  54. int httpServerSideHandler2(int status,
  55. FdEventHandlerPtr event,
  56. StreamRequestPtr srequest);
  57. int httpServerConnectionDnsHandler(int status,
  58. GethostbynameRequestPtr request);
  59. int httpServerConnectionHandler(int status,
  60. FdEventHandlerPtr event,
  61. ConnectRequestPtr request);
  62. int httpServerSocksHandler(int status, SocksRequestPtr request);
  63. int httpServerConnectionHandlerCommon(int status,
  64. HTTPConnectionPtr connection);
  65. void httpServerFinish(HTTPConnectionPtr connection, int s, int offset);
  66. void httpServerReply(HTTPConnectionPtr connection, int immediate);
  67. void httpServerAbort(HTTPConnectionPtr connection, int, int, struct _Atom *);
  68. void httpServerAbortRequest(HTTPRequestPtr request, int, int, struct _Atom *);
  69. void httpServerClientReset(HTTPRequestPtr request);
  70. void httpServerUnpipeline(HTTPRequestPtr request);
  71. int
  72. httpServerSendRequest(HTTPConnectionPtr connection);
  73. int
  74. httpServerHandler(int status,
  75. FdEventHandlerPtr event,
  76. StreamRequestPtr request);
  77. int
  78. httpServerReplyHandler(int status,
  79. FdEventHandlerPtr event,
  80. StreamRequestPtr request);
  81. int
  82. httpServerIndirectHandler(int status,
  83. FdEventHandlerPtr event,
  84. StreamRequestPtr request);
  85. int
  86. httpServerDirectHandler(int status,
  87. FdEventHandlerPtr event,
  88. StreamRequestPtr request);
  89. int
  90. httpServerDirectHandler2(int status,
  91. FdEventHandlerPtr event,
  92. StreamRequestPtr request);
  93. int httpServerRequest(ObjectPtr object, int method, int from, int to,
  94. HTTPRequestPtr, void*);
  95. int httpServerHandlerHeaders(int eof,
  96. FdEventHandlerPtr event,
  97. StreamRequestPtr request,
  98. HTTPConnectionPtr connection);
  99. int httpServerReadData(HTTPConnectionPtr, int);
  100. int connectionAddData(HTTPConnectionPtr connection, int skip);
  101. int
  102. httpWriteRequest(HTTPConnectionPtr connection, HTTPRequestPtr request, int);
  103. void listServers(FILE*);