2011-01-13 4 views
2

광산 프로젝트에서 cpp-netlib를 사용하려고합니다. 나중에 HTTP 프록시를 만들어야 일부 기능을 연결할 수 있습니다. 지금은 요청을 청취하고 새 사이트로 요청을 보내고 새 요청의 응답을 첫 번째 요청으로 전달하면됩니다. 내가 수율에게 응답 19.4kb 데이터를 사용하고 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 사용하기 - Helpless

테스트 이미지에 대한 요청에

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(); 

결과 :

내가 지금까지 가지고있는 코드입니다. 위의 코드 (헤더 복사없이)를 통해 동일한 요청을하면 브라우저가 텍스트 (기본 헤더)로 표시하려고하는 약 4KB 데이터에 대한 답을 얻습니다. 비록 텍스트에서도 이미지처럼 보입니다.

누구나 cpp-netlib-0.8에 익숙하십니까? response.content = clientResponse.body(); 올바른 방법입니까? 올바른 헤더를 추가하려면 어떻게해야합니까?

지금 당장은 cpp-netlib에 템플릿이 너무 많아서 이해가 안됩니다!

감사합니다 ... 대신 사용

답변

0

: 당신의 변수가 실제로 clientResponse있을 때, 변수로 response를 사용하고, 또한

std::string body_content = body(clientResponse); 

:

response.content = clientResponse.body(); 

올바른 방법입니다

자세한 내용은을 참조하십시오.

관련 문제