Skip to content

Commit a65aedb

Browse files
committed
HttpHeader: make buffer resizable
1 parent d35972d commit a65aedb

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

src/AudioTools/CoreAudio/AudioHttp/HttpHeader.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,6 @@ struct HttpHeaderLine {
4949
HttpHeaderLine(const char* k) { key = k; }
5050
};
5151

52-
/**
53-
* @brief workng buffer on the heap
54-
*/
55-
56-
static Vector<char> temp_buffer{0};
57-
5852
/**
5953
* @brief In a http request and reply we need to process header information.
6054
* With this API we can define and query the header information. The individual
@@ -302,7 +296,7 @@ class HttpHeader {
302296
bool isRedirectStatus() { return status_code >= 300 && status_code < 400; }
303297

304298
/// release static temp buffer
305-
static void end() { temp_buffer.resize(0); }
299+
void end() { temp_buffer.resize(0); }
306300

307301
/// Set the timout
308302
void setTimeout(int timeoutMs) { timeout_ms = timeoutMs; }
@@ -313,6 +307,11 @@ class HttpHeader {
313307
/// Defines the protocol: e.g. HTTP/1.1
314308
void setProtocol(const char* protocal) { protocol_str = protocal; }
315309

310+
/// Resizes the internal read buffer
311+
void resize(int bufferSize){
312+
temp_buffer.resize(bufferSize);
313+
}
314+
316315
protected:
317316
int status_code = UNDEFINED;
318317
bool is_written = false;
@@ -329,9 +328,9 @@ class HttpHeader {
329328
HttpLineReader reader;
330329
const char* CRLF = "\r\n";
331330
int timeout_ms = URL_CLIENT_TIMEOUT;
331+
Vector<char> temp_buffer{HTTP_MAX_LEN};
332332

333333
char* tempBuffer() {
334-
temp_buffer.resize(HTTP_MAX_LEN);
335334
temp_buffer.clear();
336335
return temp_buffer.data();
337336
}

src/AudioTools/CoreAudio/AudioHttp/HttpRequest.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class HttpRequest : public BaseStream {
2929

3030
HttpRequest() = default;
3131

32-
~HttpRequest() { HttpHeader::end(); }
32+
~HttpRequest() { end(); }
3333

3434
HttpRequest(Client &client) { setClient(client); }
3535

0 commit comments

Comments
 (0)