【发包工具】http多线程发包工具

  使用方法:输入地址,发送的内容,线程数,等待时间,每个线程发送的次数,GET/POST请求。

  源代码

  package com.xmxkkk.httptest;

  import java.awt.*;

  import java.awt.event.*;

  import javax.swing.*;

  import javax.swing.border.TitledBorder;

  public class MainWindow extends JFrame {

  // HttpClient httpclient;

  private JPanel contentPane;

  private BorderLayout borderLayout1;

  private JPanel panURL;

  private JPanel jPanel1;

  private JPanel jPanel2;

  private GridLayout gridLayout1;

  private JTextField URLTxt;

  private JSplitPane jSplitPane1;

  private JScrollPane jScrollPane1;

  private JScrollPane jScrollPane2;

  private JTextArea jTextArea1;

  private JTextArea jTextArea2;

  private JScrollPane jScrollPane3;

  private JTextArea jTextArea3;

  private JButton jButton1;

  private JButton jButton2;

  private JPanel jPanel3;

  private JRadioButton jRadioGet;

  private JRadioButton jRadioPost;

  public String method;

  private JPanel jPanel4;

  private ButtonGroup buttonGroup1;

  private JButton jButton3;

  private JCheckBox jCheckWrap;

  private BorderLayout borderLayout2;

  private TitledBorder titledBorder1;

  private JTextField thread;

  private JTextField num;

  private JTextField time;

  public MainWindow() {

  // httpclient = null;

  thread=new JTextField(5);

  num=new JTextField(5);

  time=new JTextField(5);

  borderLayout1 = new BorderLayout();

  panURL = new JPanel();

  jPanel1 = new JPanel();

  jPanel2 = new JPanel();

  gridLayout1 = new GridLayout();

  URLTxt = new JTextField();

  jSplitPane1 = new JSplitPane();

  jScrollPane1 = new JScrollPane();

  jScrollPane2 = new JScrollPane();

  jTextArea1 = new JTextArea();

  jTextArea2 = new JTextArea();

  jScrollPane3 = new JScrollPane();

  jTextArea3 = new JTextArea();

  jButton1 = new JButton();

  jButton2 = new JButton();

  jPanel3 = new JPanel();

  jRadioGet = new JRadioButton();

  jRadioPost = new JRadioButton();

  method = "POST";

  jPanel4 = new JPanel();

  buttonGroup1 = new ButtonGroup();

  jButton3 = new JButton();

  jCheckWrap = new JCheckBox();

  borderLayout2 = new BorderLayout();

  enableEvents(64L);

  try {

  jbInit();

  } catch (Exception e) {

  e.printStackTrace();

  }

  }

  private void jbInit() throws Exception {

  // httpclient = new HttpClient(this,jTextArea1);

  contentPane = (JPanel) getContentPane();

  titledBorder1 = new TitledBorder("");

  contentPane.setLayout(borderLayout1);

  setSize(new Dimension(652, 460));

  setTitle("Http testing tool");

  jPanel1.setLayout(gridLayout1);

  gridLayout1.setColumns(1);

  URLTxt.setBackground(SystemColor.desktop);

  URLTxt.setForeground(Color.yellow);

  URLTxt.setBorder(BorderFactory.createEtchedBorder());

  URLTxt.setNextFocusableComponent(jButton1);

  // URLTxt.setToolTipText("Input the connection URL");

  URLTxt.setMargin(new Insets(5, 5, 5, 5));

  URLTxt.setText("http://");

  URLTxt.addActionListener(new ActionListener() {

  public void actionPerformed(ActionEvent e) {

  URLTxt_actionPerformed(e);

  }

  });

  jSplitPane1.setOrientation(0);

  jSplitPane1.setDividerSize(8);

  // jTextArea1.setToolTipText("Edit the request xml");

  jTextArea1.setText("");

  jTextArea2.setText("");

  jTextArea3.setForeground(Color.blue);

  // jTextArea3.setToolTipText("Recived message");

  jTextArea3.setText("");

  jTextArea3.setLineWrap(true);

  jTextArea3.setWrapStyleWord(true);

  jButton1.setText("Send");

  jButton1.addActionListener(new ActionListener() {

  public void actionPerformed(ActionEvent e) {

  jButton1_actionPerformed(e);

  }

  });

  jButton2.setText("Exit");

  jButton2.addActionListener(new ActionListener() {

  public void actionPerformed(ActionEvent e) {

  jButton2_actionPerformed(e);

  }

  });

  jRadioGet.setForeground(new Color(0, 0, 230));

  jRadioGet.setText("GET");

  jRadioGet.addActionListener(new ActionListener() {

  public void actionPerformed(ActionEvent e) {

  jRadioGet_actionPerformed(e);

  }

  });

  jRadioPost.setForeground(new Color(0, 0, 230));

  jRadioPost.setText("POST");

  jRadioPost.addActionListener(new ActionListener() {

  public void actionPerformed(ActionEvent e) {

  jRadioPost_actionPerformed(e);

  }

  });

  panURL.setLayout(borderLayout2);

  jButton3.setText("Clear");

  jButton3.addActionListener(new ActionListener() {

  public void actionPerformed(ActionEvent e) {

  jButton3_actionPerformed(e);

  }

  });

  jCheckWrap.setSelected(true);

  jCheckWrap.setText("LineWrap");

  jCheckWrap.addActionListener(new ActionListener() {

  public void actionPerformed(ActionEvent e) {

  jCheckWrap_actionPerformed(e);

  }

  });

  contentPane.add(jPanel1, "Center");

  contentPane.add(panURL, "North");

  contentPane.add(jPanel2, "South");

  panURL.add(URLTxt, "Center");

  jPanel2.add(new JLabel("线程"));

  jPanel2.add(thread,null);

  jPanel2.add(new JLabel("次数"));

  jPanel2.add(num,null);

  jPanel2.add(new JLabel("延时"));

  jPanel2.add(time,null);

  jPanel2.add(jCheckWrap, null);

  jPanel2.add(jPanel4, null);

  jPanel2.add(jPanel3, null);

  jPanel3.add(jRadioGet, null);

  jPanel3.add(jRadioPost, null);

  jRadioPost.setSelected(true);

  buttonGroup1.add(jRadioGet);

  buttonGroup1.add(jRadioPost);

  jPanel2.add(jButton1, null);

  jPanel2.add(jButton3, null);

  jPanel2.add(jButton2, null);

  jPanel1.add(jSplitPane1, null);

  jSplitPane1.add(jScrollPane1, "top");

  jSplitPane1.add(jScrollPane3, "bottom");

  jScrollPane3.getViewport().add(jTextArea3, null);

  jScrollPane1.getViewport().add(jTextArea1, null);

  jScrollPane2.getViewport().add(jTextArea2, null);

  jSplitPane1.setDividerLocation(100);

  }

  protected void processWindowEvent(WindowEvent e) {

  super.processWindowEvent(e);

  if (e.getID() == 201)

  System.exit(0);

  }

  void jButton1_actionPerformed(ActionEvent e) {

  // String soMethod = String.valueOf(String.valueOf((new StringBuffer("Method: ")).append(method).append(":\n")));

  String url = URLTxt.getText();

  String xml = jTextArea1.getText();

  String str=thread.getText();

  int cnt=1;

  if(str==null||str.equals("")){

  cnt=1;

  thread.setText(cnt+"");

  }else{

  cnt=Integer.parseInt(str);

  thread.setText(cnt+"");

  }

  String abc=num.getText();

  int every=1;

  if(abc==null||abc.equals("")){

  every=1;

  num.setText(every+"");

  }else{

  every=Integer.parseInt(abc);

  num.setText(every+"");

  }

  String div=time.getText();

  int divI=0;

  if(div==null||div.equals("")){

  divI=0;

  time.setText(divI+"");

  }else{

  divI=Integer.parseInt(div);

  time.setText(divI+"");

  }

  for(int i=0;i -1)

  sb.append((char) ch);

  rec_string = sb.toString();

  rd.close();

  urlconn.disconnect();

  } catch (Exception e) {

  log = String.valueOf(String.valueOf((new StringBuffer("请求错误:"))

  .append(e.getMessage()).append(e.toString())));

  writeLog(log);

  }

  return rec_string;

  }

  private String getMethod() {

  if (mwindow == null)

  return "GET";

  else

  return mwindow.method;

  }

  private void writeLog(String s) {

  if (mwindow == null)

  System.out.println(s);

  else

  mwindow.showMsg(String.valueOf(String.valueOf(s)).concat("\n"));

  }

  public static void main(String args[]) {

  }

  @Override

  public void run() {

  for(int i=0;i screenSize.height)

  frameSize.height = screenSize.height;

  if (frameSize.width > screenSize.width)

  frameSize.width = screenSize.width;

  frame.setLocation((screenSize.width - frameSize.width) / 2,

  (screenSize.height - frameSize.height) / 2);

  frame.setVisible(true);

  }

  public static void main(String args[]) {

  try {

  //

  UIManager.setLookAndFeel(UIManager

  .getCrossPlatformLookAndFeelClassName());

  UIManager

  .setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");

  // SwingUtilities.updateComponentTreeUI(this);

  } catch (Exception e) {

  e.printStackTrace();

  }

  new HttpTest();

  }

  }

【发包工具】http多线程发包工具的更多相关文章

  1. Java 并发包中的高级同步工具

    Java 并发包中的高级同步工具 Java 中的并发包指的是 java.util.concurrent(简称 JUC)包和其子包下的类和接口,它为 Java 的并发提供了各种功能支持,比如: 提供了线 ...

  2. Mysql多线程性能测试工具sysbench 安装、使用和测试

    From:http://www.cnblogs.com/zhoujinyi/archive/2013/04/19/3029134.html 摘要:      sysbench是一个开源的.模块化的.跨 ...

  3. 开源多线程性能测试工具-sysbench

    导读 sysbench是一款开源的多线程性能测试工具,可以执行CPU/内存/线程/IO/数据库等方面的性能测试.数据库目前支持MySQL/Oracle/PostgreSQL.本文主要演示Mysql测试 ...

  4. linux多线程下载工具mwget

    linux多线程下载工具mwget 经常使用wget进行文件下载,然而wget的处理速度并不如人意.遇到一些国外的站点,经常慢得像蜗牛一般.然而为了解决这个问题,便有了mwget:m表示multi多线 ...

  5. CentOS6.4 安装aria2多线程下载工具

    aria2是一个Linux下的多线程下载工具,支持HTTP/HTTPS.FTP.BitTorrent.Metalink协议. 平时在linux上下载http上的东西常用如wget.curl命令,但是他 ...

  6. MySQL多线程备份工具:mydumper

    MySQL多线程备份工具:mydumper http://www.orczhou.com/index.php/2011/12/how-to-split-mysqldump-file/ Mydumper ...

  7. Linux下多线程下载工具myget

    [root@superdba ~]# mytgetMytget 0.0.99: A download accelerator for GNU/LinuxUsage: mytget [options]. ...

  8. Linux 下的多线程下载工具 Axel

    Axel 是 Linux 平台下的一款 HTTP/FTP 的高速下载工具,支持多线程以及断点续传,对于一些有速度限制的服务器上下载东西时,Axel 的速度就明显比 wget 要快一些 还有另一个基于 ...

  9. Java并发多线程 - 并发工具类JUC

    安全共享对象策略 1.线程限制 : 一个被线程限制的对象,由线程独占,并且只能被占有它的线程修改 2.共享只读 : 一个共享只读的对象,在没有额外同步的情况下,可以被多个线程并发访问, 但是任何线程都 ...

随机推荐

  1. tf.Variable

    tf.Variable __init__( initial_value=None, trainable=True, collections=None, validate_shape=True, cac ...

  2. NewStyleClass学习笔记[一]

    from : https://www.python.org/doc/newstyle/ New-style Classes Unfortunately(遗憾,不幸的), new-style class ...

  3. java你可能不知道的事(2)--堆和栈<转>

    在java语言的学习和使用当中你可能已经了解或者知道堆和栈,但是你可能没有完全的理解它们.今天我们就一起来学习堆.栈的特点以及它们的区别.认识了这个之后,你可能对java有更深的理解. Java堆内存 ...

  4. HTTP 响应头信息(Http Response Header) Content-Length 和 Transfer-Encoding

    Tomcat 中响应头信息(Http Response Header) Content-Length 和 Transfer-Encoding 客户端(PC浏览器或者手机浏览器)在接受到Tomcat的响 ...

  5. hive中使用with as查询作为临时中间表

    oracle.hive都存在with as的用法.用于将重复的查询结果复用. 今天做统计分析时用到,使用例子如下: 1. 直接查询 with tmp_a as ( select f1,f2,f3 fr ...

  6. PHP与Java进行通信的实现方法

    缘起: 最近做了一个电商平台与网银整合的小东西,程序是开源的 Ecmall的,网银的接口也很规范,给出的文档很全,唯一的小问题是,网银使用的签名和验签的lib是只有java和c的,对java还熟悉一些 ...

  7. C/C++中near和far的区别

    C/C++中near和far的区别 关键字near和far受目标计算机体系结构的影响.目前编程中使用不多. near关键字创建一个指向可寻址内存低端部分的目标指针.这些指针占用内存的单一字节,并且他们 ...

  8. IIS字体文件添加MIME映射

    在前端经常会做这样一件事情,页面会加载一些特殊的字体或者是图标文件,常用的比如:.woff.woff2..ttf..svg..otf..eot...如果没有添加MIME映射会报404的错误,IIS错误 ...

  9. Python __init__函数的使用

    class Cat: def __init__(self,_name): self.name = _name def eat(self): print("i am eating ." ...

  10. 5、QT分析之网络编程

    原文地址:http://blog.163.com/net_worm/blog/static/127702419201002842553382/ 首先对Windows下的网络编程总结一下: 如果是服务器 ...