~ubuntu-branches/ubuntu/vivid/reminders-app/vivid-proposed

« back to all changes in this revision

Viewing changes to 3rdParty/libthrift/async/TEvhttpServer.h

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release
  • Date: 2014-07-04 07:35:58 UTC
  • Revision ID: package-import@ubuntu.com-20140704073558-t2grq61xc07lv2bh
Tags: upstream-0.4+14.10.20140704
ImportĀ upstreamĀ versionĀ 0.4+14.10.20140704

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Licensed to the Apache Software Foundation (ASF) under one
 
3
 * or more contributor license agreements. See the NOTICE file
 
4
 * distributed with this work for additional information
 
5
 * regarding copyright ownership. The ASF licenses this file
 
6
 * to you under the Apache License, Version 2.0 (the
 
7
 * "License"); you may not use this file except in compliance
 
8
 * with the License. You may obtain a copy of the License at
 
9
 *
 
10
 *   http://www.apache.org/licenses/LICENSE-2.0
 
11
 *
 
12
 * Unless required by applicable law or agreed to in writing,
 
13
 * software distributed under the License is distributed on an
 
14
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 
15
 * KIND, either express or implied. See the License for the
 
16
 * specific language governing permissions and limitations
 
17
 * under the License.
 
18
 */
 
19
 
 
20
#ifndef _THRIFT_TEVHTTP_SERVER_H_
 
21
#define _THRIFT_TEVHTTP_SERVER_H_ 1
 
22
 
 
23
#include <boost/shared_ptr.hpp>
 
24
 
 
25
struct event_base;
 
26
struct evhttp;
 
27
struct evhttp_request;
 
28
 
 
29
namespace apache { namespace thrift { namespace async {
 
30
 
 
31
class TAsyncBufferProcessor;
 
32
 
 
33
class TEvhttpServer {
 
34
 public:
 
35
  /**
 
36
   * Create a TEvhttpServer for use with an external evhttp instance.
 
37
   * Must be manually installed with evhttp_set_cb, using
 
38
   * TEvhttpServer::request as the callback and the
 
39
   * address of the server as the extra arg.
 
40
   * Do not call "serve" on this server.
 
41
   */
 
42
  TEvhttpServer(boost::shared_ptr<TAsyncBufferProcessor> processor);
 
43
 
 
44
  /**
 
45
   * Create a TEvhttpServer with an embedded event_base and evhttp,
 
46
   * listening on port and responding on the endpoint "/".
 
47
   * Call "serve" on this server to serve forever.
 
48
   */
 
49
  TEvhttpServer(boost::shared_ptr<TAsyncBufferProcessor> processor, int port);
 
50
 
 
51
  ~TEvhttpServer();
 
52
 
 
53
  static void request(struct evhttp_request* req, void* self);
 
54
  int serve();
 
55
 
 
56
  struct event_base* getEventBase();
 
57
 
 
58
 private:
 
59
  struct RequestContext;
 
60
 
 
61
  void process(struct evhttp_request* req);
 
62
  void complete(RequestContext* ctx, bool success);
 
63
 
 
64
  boost::shared_ptr<TAsyncBufferProcessor> processor_;
 
65
  struct event_base* eb_;
 
66
  struct evhttp* eh_;
 
67
};
 
68
 
 
69
}}} // apache::thrift::async
 
70
 
 
71
#endif // #ifndef _THRIFT_TEVHTTP_SERVER_H_