|
|
|
Получить заголовки в скрипте асинхронного скачивания apache.http.client
|
|||
|---|---|---|---|
|
#18+
import java.net.URI; import java.net.URISyntaxException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; import org.apache.http.client.fluent.Async; import org.apache.http.client.fluent.Content; import org.apache.http.client.fluent.Request; import org.apache.http.client.utils.URIBuilder; import org.apache.http.concurrent.FutureCallback; /** * Java mass loader */ public class MassLoader { /** * Main method * * @param args */ public static void main(String[] args) { URIBuilder builder = new URIBuilder(); builder.setScheme("http").setHost("google.com").setPath("/"); URI requestURL = null; try { requestURL = builder.build(); } catch (URISyntaxException use) {} ExecutorService threadpool = Executors.newFixedThreadPool(100); Async async = Async.newInstance().use(threadpool); final Request request = Request.Get(requestURL); for(int i=0; i < 100; i++) { Future<Content> future = async.execute(request, new FutureCallback<Content>() { public void failed (final Exception e) { System.out.println(e.getMessage() +": "+ request); } public void completed (final Content content) { System.out.println("Request completed: "+ request); System.out.println("Response:\n"+ content.asString()); } public void cancelled () { System.out.print("Cancelled"); } }); } } } ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 09.04.2015, 00:14 |
|
||
|
Получить заголовки в скрипте асинхронного скачивания apache.http.client
|
|||
|---|---|---|---|
|
#18+
Подскажите как можно в этом скрипте получить headers все в виде массива ? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 09.04.2015, 00:15 |
|
||
|
|

start [/forum/topic.php?fid=59&gotonew=1&tid=2125573]: |
0ms |
get settings: |
10ms |
get forum list: |
15ms |
check forum access: |
3ms |
check topic access: |
3ms |
track hit: |
157ms |
get topic data: |
9ms |
get first new msg: |
5ms |
get forum data: |
2ms |
get page messages: |
44ms |
get tp. blocked users: |
1ms |
| others: | 245ms |
| total: | 494ms |

| 0 / 0 |
