Esempio n. 1
0
        public static AwsHttpRequest create_kinesis_request(string region, string api_method, string data)
        {
            AwsHttpRequest awsHttpRequest = new AwsHttpRequest(string.IsNullOrEmpty(data) ? "GET" : "POST", "/", "HTTP/1.1");

            awsHttpRequest.add_header("Host", "kinesis." + region + ".amazonaws.com");
            awsHttpRequest.add_header("Connection", "Keep-Alive");
            awsHttpRequest.add_header("X-Amz-Target", "Kinesis_20131202." + api_method);
            awsHttpRequest.add_header("User-Agent", AwsHttp.user_agent());
            if (!string.IsNullOrEmpty(data))
            {
                awsHttpRequest.add_header("Content-Type", "application/x-amz-json-1.1");
            }
            StdErrorOut.Instance.StdOut(LogLevel.debug, "before req.set_data(data)");
            awsHttpRequest.set_data(data);
            StdErrorOut.Instance.StdOut(LogLevel.debug, "after req.set_data(data)");
            return(awsHttpRequest);
        }
Esempio n. 2
0
 public void put(AwsHttpRequest request, ResponseCallback cb, object context, DateTime deadline, DateTime expiration)
 {
     lock (mutex_)
     {
         task_queue_.insert(new SocketTask(
                                executor_,
                                request,
                                context,
                                cb,
                                (socket) => { reuse_socket(socket); },
                                deadline,
                                expiration,
                                (int)requestTimeout));
     }
     run_tasks();
     StdErrorOut.Instance.StdOut(LogLevel.debug, "before run_tasks");
 }
Esempio n. 3
0
        public void Get(string path, Callback callback)
        {
            var done = false;

            executor_.Schedule(() => { if (!done)
                                       {
                                           done = true; callback(false, "Timed out");
                                       }
                               }, kTimeout);

            AwsHttpRequest req = new AwsHttpRequest("GET", path);

            http_client_.put(req, (result) => { if (!done)
                                                {
                                                    done = true; callback(result.successful(), result.successful() ? result.response_body() : result.error());
                                                }
                             }, new object(), DateTime.Now, DateTime.Now);
        }
Esempio n. 4
0
 public SocketTask(Executor executor,
                   AwsHttpRequest request,
                   object context,
                   ResponseCallback response_cb,
                   SocketReturn socketReturn,
                   DateTime deadline,
                   DateTime expiration,
                   int timeout)
     : base(deadline, expiration)
 {
     executor_     = executor;
     raw_request_  = request.to_string();
     context_      = context;
     response_cb_  = response_cb;
     socketReturn_ = socketReturn;
     timeout_      = timeout;
     response_     = new AwsHttpResponse();
     finished_     = false;
 }