Switch from BHttpRequest to BProtocolRoster for requests
This commit is contained in:
parent
12368433cd
commit
d6975dbc98
13
src/Util.cpp
13
src/Util.cpp
|
@ -3,7 +3,9 @@
|
||||||
#include <locale>
|
#include <locale>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <DateTime.h>
|
#include <DateTime.h>
|
||||||
#include <HttpRequest.h>
|
#include <UrlProtocolRoster.h>
|
||||||
|
#include <Url.h>
|
||||||
|
#include <UrlRequest.h>
|
||||||
#include <boost/uuid/detail/sha1.hpp>
|
#include <boost/uuid/detail/sha1.hpp>
|
||||||
#include "ProtocolListener.h"
|
#include "ProtocolListener.h"
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
|
@ -98,19 +100,18 @@ int32
|
||||||
webFetch ( BUrl url, BDataIO* reply, BString* hash )
|
webFetch ( BUrl url, BDataIO* reply, BString* hash )
|
||||||
{
|
{
|
||||||
ProtocolListener listener(true);
|
ProtocolListener listener(true);
|
||||||
BUrlContext context;
|
|
||||||
boost::uuids::detail::sha1 sha1;
|
boost::uuids::detail::sha1 sha1;
|
||||||
|
|
||||||
BHttpRequest request( url, true, "HTTP", &listener, &context );
|
BUrlRequest* request = BUrlProtocolRoster::MakeRequest( url, &listener );
|
||||||
|
|
||||||
listener.SetDownloadIO( reply );
|
listener.SetDownloadIO( reply );
|
||||||
listener.SetSha1( &sha1 );
|
listener.SetSha1( &sha1 );
|
||||||
|
|
||||||
thread_id thread = request.Run();
|
thread_id thread = request->Run();
|
||||||
wait_for_thread( thread, NULL );
|
wait_for_thread( thread, NULL );
|
||||||
|
|
||||||
*(hash) = listener.GetHash();
|
*(hash) = listener.GetHash();
|
||||||
|
|
||||||
const BHttpResult& result = dynamic_cast<const BHttpResult&>( request.Result() );
|
return request->Status();
|
||||||
return result.StatusCode();
|
return 200;
|
||||||
}
|
}
|
||||||
|
|
Ŝarĝante…
Reference in New Issue