2 * Copyright 2010 Haiku Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
6 * Christophe Huriaux, c.huriaux@gmail.com
11 #include <UrlSynchronousRequest.h>
13 #define PRINT(x) printf x;
16 BUrlSynchronousRequest::BUrlSynchronousRequest(BUrlRequest
& request
)
18 BUrlRequest(request
.Url(), NULL
, request
.Context(),
19 "BUrlSynchronousRequest", request
.Protocol()),
20 fRequestComplete(false),
21 fWrappedRequest(request
)
27 BUrlSynchronousRequest::Perform()
29 fWrappedRequest
.SetListener(this);
30 fRequestComplete
= false;
32 thread_id worker
= fWrappedRequest
.Run();
33 // TODO something to do with the thread_id maybe ?
43 BUrlSynchronousRequest::WaitUntilCompletion()
45 while (!fRequestComplete
)
53 BUrlSynchronousRequest::ConnectionOpened(BUrlRequest
*)
55 PRINT(("SynchronousRequest::ConnectionOpened()\n"));
60 BUrlSynchronousRequest::HostnameResolved(BUrlRequest
*, const char* ip
)
62 PRINT(("SynchronousRequest::HostnameResolved(%s)\n", ip
));
67 BUrlSynchronousRequest::ResponseStarted(BUrlRequest
*)
69 PRINT(("SynchronousRequest::ResponseStarted()\n"));
74 BUrlSynchronousRequest::HeadersReceived(BUrlRequest
*, const BUrlResult
& result
)
76 PRINT(("SynchronousRequest::HeadersReceived()\n"));
81 BUrlSynchronousRequest::DataReceived(BUrlRequest
*, const char*,
84 PRINT(("SynchronousRequest::DataReceived(%zd)\n", size
));
89 BUrlSynchronousRequest::DownloadProgress(BUrlRequest
*,
90 ssize_t bytesReceived
, ssize_t bytesTotal
)
92 PRINT(("SynchronousRequest::DownloadProgress(%zd, %zd)\n", bytesReceived
,
98 BUrlSynchronousRequest::UploadProgress(BUrlRequest
*, ssize_t bytesSent
,
101 PRINT(("SynchronousRequest::UploadProgress(%zd, %zd)\n", bytesSent
,
107 BUrlSynchronousRequest::RequestCompleted(BUrlRequest
* caller
, bool success
)
109 PRINT(("SynchronousRequest::RequestCompleted(%s) : %s\n", (success
?"true":"false"),
110 strerror(caller
->Status())));
111 fRequestComplete
= true;