MCPcopy Create free account
hub / github.com/BlueAndi/Pixelix / onResponse

Method onResponse

lib/HttpService/src/HttpFileResponseHandler.cpp:75–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73}
74
75void HttpFileResponseHandler::onResponse(uint32_t index, bool isFinal, const uint8_t* payload, size_t size)
76{
77 if (0U == index)
78 {
79 m_isError = false;
80 m_file = FILESYSTEM.open(m_filePath, FILE_WRITE);
81
82 if (false == m_file)
83 {
84 LOG_ERROR("Unable to open file %s for writing HTTP response.", m_filePath.c_str());
85 m_isError = true;
86 }
87 else
88 {
89 LOG_DEBUG("Writing HTTP response to file %s.", m_filePath.c_str());
90 }
91 }
92
93 if (true == m_file)
94 {
95 if (size != m_file.write(payload, size))
96 {
97 LOG_ERROR("Unable to write HTTP response to file %s.", m_filePath.c_str());
98 m_isError = true;
99 }
100
101 if (true == m_isError)
102 {
103 m_file.close();
104 }
105 else if (true == isFinal)
106 {
107 LOG_DEBUG("Finished writing HTTP response to file %s.", m_filePath.c_str());
108 m_file.close();
109 }
110 else
111 {
112 /* Continue writing. */
113 ;
114 }
115 }
116}
117
118/******************************************************************************
119 * Protected Methods

Callers 1

handleHttpResponseMethod · 0.45

Calls 4

c_strMethod · 0.80
openMethod · 0.45
writeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected