Poco を使用して C++ で HTTP クライアントを作成していますが、サーバーが jpeg 画像コンテンツ (バイト単位) を含む応答を送信する状況があります。クライアントが応答を処理し、それらのバイトから jpg 画像ファイルを生成する必要があります。
Poco ライブラリで適切な関数を検索しましたが、見つかりませんでした。それを行う唯一の方法は手動であるようです。
これは私のコードの一部です。応答を受け取り、入力ストリームを画像コンテンツの先頭から開始します。
/* Get response */
HTTPResponse res;
cout << res.getStatus() << " " << res.getReason() << endl;
istream &is = session.receiveResponse(res);
/* Download the image from the server */
char *s = NULL;
int length;
std::string slength;
for (;;) {
is.getline(s, '\n');
string line(s);
if (line.find("Content-Length:") < 0)
continue;
slength = line.substr(15);
slength = trim(slength);
stringstream(slength) >> length;
break;
}
/* Make `is` point to the beginning of the image content */
is.getline(s, '\n');
どうやって進める?