-
Notifications
You must be signed in to change notification settings - Fork 70
/
Copy pathHttpRequestTest.cpp
48 lines (33 loc) · 1.52 KB
/
HttpRequestTest.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/crt/Api.h>
#include <aws/crt/http/HttpRequestResponse.h>
#include <aws/http/request_response.h>
#include <aws/testing/aws_test_harness.h>
#include <sstream>
using namespace Aws::Crt::Http;
static int s_HttpRequestTestCreateDestroy(struct aws_allocator *allocator, void *ctx)
{
(void)ctx;
{
Aws::Crt::ApiHandle apiHandle(allocator);
Aws::Crt::Http::HttpRequest request(allocator);
request.SetMethod(aws_byte_cursor_from_c_str("GET"));
request.SetPath(aws_byte_cursor_from_c_str("/index"));
std::shared_ptr<Aws::Crt::Io::IStream> stream = std::make_shared<std::stringstream>("TestContent");
request.SetBody(stream);
std::shared_ptr<Aws::Crt::Io::IStream> stream2 = std::make_shared<std::stringstream>("SomeOtherContent");
request.SetBody(stream2);
HttpHeader header1 = {aws_byte_cursor_from_c_str("Host"), aws_byte_cursor_from_c_str("www.test.com")};
request.AddHeader(header1);
HttpHeader header2 = {aws_byte_cursor_from_c_str("Authorization"), aws_byte_cursor_from_c_str("sadf")};
request.AddHeader(header2);
HttpHeader header3 = {aws_byte_cursor_from_c_str("UserAgent"), aws_byte_cursor_from_c_str("unit-tests-1.0")};
request.AddHeader(header3);
request.EraseHeader(2);
}
return AWS_OP_SUCCESS;
}
AWS_TEST_CASE(HttpRequestTestCreateDestroy, s_HttpRequestTestCreateDestroy)