Esempio n. 1
0
void test_requestbuilder_BuildsWithHeaders(void)
{
    builder.putHeader("Host", "www.example.com");
    builder.putHeader("Content-Type", "text/html");
    builder.putHeader("Some-Other-Header", "Some-Other-Value");
    builder.writeToBuffer(requestBuffer, 512);
    TEST_ASSERT_EQUAL_STRING(
        "GET / HTTP/1.1\r\n"
        "Host: www.example.com\r\n"
        "Content-Type: text/html\r\n"
        "Some-Other-Header: Some-Other-Value\r\n", requestBuffer);
}
Esempio n. 2
0
void test_requestbuilder_BuildsWithContentLengthHeader(void)
{
    builder.writeToBuffer(requestBuffer, 512, true);
    TEST_ASSERT_EQUAL_STRING(
        "GET / HTTP/1.1\r\n"
        "Host: www.example.com\r\n"
        "Content-Type: text/html\r\n"
        "Some-Other-Header: Some-Other-Value\r\n"
        "Content-Length: 30\r\n"
        "\r\n"
        "This is some data in the body.\r\n", requestBuffer);
}
Esempio n. 3
0
void test_requestbuilder_BuildsWithURLParameters(void)
{
    builder.reset();
    builder.setMethodAndURL("GET", "/update"); 
    builder.setURLParam("Param1", "Param1Value");
    builder.setURLParam("Param2", "Param2Value");
    builder.putHeader("Host", "www.example.com");
    builder.putBody(NULL);

    builder.writeToBuffer(requestBuffer, 512);

    TEST_ASSERT_EQUAL_STRING(
        "GET /update?Param1=Param1Value&Param2=Param2Value HTTP/1.1\r\n"
        "Host: www.example.com\r\n", requestBuffer); 
}
Esempio n. 4
0
void test_requestbuilder_BuildsWithMethodAndURLOnly(void)
{
    builder.setMethodAndURL("GET", "/");   
    builder.writeToBuffer(requestBuffer, 512);
    TEST_ASSERT_EQUAL_STRING("GET / HTTP/1.1\r\n", requestBuffer);
}