2011-01-13 7 views
2

私のプロジェクトでcpp-netlibを使用しようとしています。後でいくつかの機能をプラグインできるHTTPプロキシを作成するだけです。今のところ、リクエストを聞いて、新しいサイトにリクエストを送り、最初のリクエストに新しいリクエストの答えを転送するだけです。 error C2679: binary '=' : no operator found which takes a right-hand operand of type 'std::multimap<_Kty,_Ty>' (or there is no acceptable conversion) HTTPプロキシとしてのcpp-netlib 0.8の使用 - 無力

std::string ip = source(request); 
http::client client; 
std::ostringstream url; 
url << "www.example.com/image.jpg"; 
http::client::request clientRequest(url.str()); 
http::client::response clientResponse = client.get(clientRequest); 
response = server::response::stock_reply(server::response::ok); 
response.headers = clientResponse.headers(); //This is not possible - not correct type or something 
response.content = clientResponse.body(); 

結果、私が受けて利回りの19.4キロバイトのデータを使用していたテスト画像への要求:

これは私がこれまで持っているコードです。私が上記のコード(ヘッダーのコピーなし)で同じリクエストを行うと、ブラウザがテキスト(デフォルトヘッダー)として表示しようとする約4kbのデータが返されます。テキストの中でさえ、イメージのように見えます。

誰でも、cpp-netlib-0.8に精通していますか?正しい方法はresponse.content = clientResponse.body();ですか?正しいヘッダーを追加するにはどうすればよいですか?

今私はそれを理解するには、cpp-netlibでテンプレートが奇妙すぎます。

おかげで...代わりに使用しての

答えて

0

:あなたの変数は、実際にclientResponseているときに、変数としてresponseを使用している、また

std::string body_content = body(clientResponse); 

response.content = clientResponse.body(); 

正しい方法があります

さらに例を読むcpp-netlib v0.8 documentation

関連する問題