Skip to content

feat(common): Add HttpTool #2142

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
May 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
383 changes: 383 additions & 0 deletions common/src/main/java/com/tlcsdm/jfxcommon/debug/HttpTool.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ private void addPort(String portString, List<String> portsList) {
}
}

public void setTableColumnMapValueFactory(TableColumn tableColumn, String name, boolean isEdit,
private void setTableColumnMapValueFactory(TableColumn tableColumn, String name, boolean isEdit,
Runnable onEditCommitHandle) {
tableColumn.setCellValueFactory(new MapValueFactory(name));
tableColumn.setCellFactory(TextFieldTableCell.<Map<String, String>>forTableColumn());
Expand Down
1 change: 1 addition & 0 deletions common/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
requires org.apache.commons.text;
requires java.net.http;
requires org.apache.commons.configuration2;
requires static org.fxmisc.flowless;

exports com.tlcsdm.jfxcommon;
exports com.tlcsdm.jfxcommon.provider to com.tlcsdm.frame;
Expand Down
189 changes: 189 additions & 0 deletions common/src/main/resources/com/tlcsdm/jfxcommon/fxml/httpTool.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
~ Copyright (c) 2024 unknowIfGuestInDream.
~ All rights reserved.
~
~ Redistribution and use in source and binary forms, with or without
~ modification, are permitted provided that the following conditions are met:
~ * Redistributions of source code must retain the above copyright
~ notice, this list of conditions and the following disclaimer.
~ * Redistributions in binary form must reproduce the above copyright
~ notice, this list of conditions and the following disclaimer in the
~ documentation and/or other materials provided with the distribution.
~ * Neither the name of unknowIfGuestInDream, any associated website, nor the
~ names of its contributors may be used to endorse or promote products
~ derived from this software without specific prior written permission.
~
~ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
~ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
~ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
~ DISCLAIMED. IN NO EVENT SHALL UNKNOWIFGUESTINDREAM BE LIABLE FOR ANY
~ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
~ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
~ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
~ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
~ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
~ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->


<?import com.tlcsdm.core.javafx.richtext.InformationArea?>
<?import com.tlcsdm.core.javafx.richtext.JsonCodeArea?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.CheckBox?>
<?import javafx.scene.control.ChoiceBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.Tab?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.control.TabPane?>
<?import javafx.scene.control.TextArea?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.StackPane?>
<?import javafx.scene.layout.VBox?>
<?import org.fxmisc.flowless.VirtualizedScrollPane?>
<AnchorPane prefHeight="520.0" prefWidth="854.0" xmlns="http://javafx.com/javafx/8.0.171"
xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.tlcsdm.jfxcommon.debug.HttpTool">
<children>
<BorderPane prefHeight="200.0" prefWidth="200.0" AnchorPane.bottomAnchor="10.0" AnchorPane.leftAnchor="10.0"
AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="10.0">
<top>
<HBox alignment="CENTER" spacing="5.0" BorderPane.alignment="CENTER">
<children>
<Label text="%common.tool.debug.httpTool.label.url"/>
<TextField fx:id="urlTextField" promptText="%common.tool.debug.httpTool.prompt.url"
text="https://api.github.com" HBox.hgrow="ALWAYS"/>
<Label text="%common.tool.debug.httpTool.label.method"/>
<ChoiceBox fx:id="methodChoiceBox" prefWidth="150.0"/>
<Button fx:id="sendButton" mnemonicParsing="false" onAction="#sendAction"
text="%common.tool.debug.httpTool.button.send"/>
<Button fx:id="toBrowerButton" mnemonicParsing="false" onAction="#toBrowerAction"
text="%common.tool.debug.httpTool.button.toBrowser"/>
</children>
</HBox>
</top>
<left>
<VBox spacing="5.0" BorderPane.alignment="CENTER">
<children>
<HBox alignment="CENTER_LEFT" spacing="5.0">
<children>
<CheckBox fx:id="paramsDataCheckBox" mnemonicParsing="false" selected="true"
text="%common.tool.debug.httpTool.checkbox.paramsData"/>
<Button fx:id="addParamsDataButton" mnemonicParsing="false"
onAction="#addParamsDataAction" text="%common.tool.debug.httpTool.button.add"/>
<CheckBox fx:id="paramsDataIsStringCheckBox" mnemonicParsing="false"
text="%common.tool.debug.httpTool.checkbox.string"/>
</children>
</HBox>
<StackPane>
<children>
<TextArea fx:id="paramsDataTextArea" prefHeight="200.0" prefWidth="200.0"
visible="false"/>
<TableView fx:id="paramsDataTableView" editable="true">
<columns>
<TableColumn fx:id="paramsDataNameTableColumn" prefWidth="59.0"
text="%common.tool.debug.httpTool.column.paramName"/>
<TableColumn fx:id="paramsDataValueTableColumn" prefWidth="73.0"
text="%common.tool.debug.httpTool.column.paramValue"/>
<TableColumn fx:id="paramsDataRemarkTableColumn" prefWidth="75.0"
text="%common.tool.debug.httpTool.column.remark"/>
</columns>
<columnResizePolicy>
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY"/>
</columnResizePolicy>
</TableView>
</children>
</StackPane>
<HBox alignment="CENTER_LEFT" spacing="5.0">
<children>
<CheckBox fx:id="paramsHeaderCheckBox" mnemonicParsing="false" selected="true"
text="%common.tool.debug.httpTool.checkbox.header"/>
<Button fx:id="addParamsHeaderButton" mnemonicParsing="false"
onAction="#addParamsHeaderAction"
text="%common.tool.debug.httpTool.button.add"/>
</children>
</HBox>
<TableView fx:id="paramsHeaderTableView" editable="true">
<columns>
<TableColumn fx:id="paramsHeaderNameTableColumn" prefWidth="75.0"
text="%common.tool.debug.httpTool.column.paramName"/>
<TableColumn fx:id="paramsHeaderValueTableColumn" prefWidth="75.0"
text="%common.tool.debug.httpTool.column.paramValue"/>
<TableColumn fx:id="paramsHeaderRemarkTableColumn" prefWidth="75.0"
text="%common.tool.debug.httpTool.column.remark"/>
</columns>
<columnResizePolicy>
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY"/>
</columnResizePolicy>
</TableView>
<HBox alignment="CENTER_LEFT" spacing="5.0">
<children>
<CheckBox fx:id="paramsCookieCheckBox" mnemonicParsing="false" selected="true"
text="%common.tool.debug.httpTool.checkbox.cookie"/>
<Button fx:id="addParamsCookieButton" mnemonicParsing="false"
onAction="#addParamsCookieAction"
text="%common.tool.debug.httpTool.button.add"/>
</children>
</HBox>
<TableView fx:id="paramsCookieTableView" editable="true">
<columns>
<TableColumn fx:id="paramsCookieNameTableColumn" prefWidth="75.0"
text="%common.tool.debug.httpTool.column.paramName"/>
<TableColumn fx:id="paramsCookieValueTableColumn" prefWidth="75.0"
text="%common.tool.debug.httpTool.column.paramValue"/>
<TableColumn fx:id="paramsCookieRemarkTableColumn" prefWidth="75.0"
text="%common.tool.debug.httpTool.column.remark"/>
</columns>
<columnResizePolicy>
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY"/>
</columnResizePolicy>
</TableView>
</children>
</VBox>
</left>
<center>
<TabPane prefHeight="200.0" prefWidth="200.0" tabClosingPolicy="UNAVAILABLE"
BorderPane.alignment="CENTER">
<tabs>
<Tab text="%common.tool.debug.httpTool.tab.responseContent">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<VirtualizedScrollPane AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<content>
<JsonCodeArea fx:id="ResponseBodyTextArea"/>
</content>
</VirtualizedScrollPane>
</children>
</AnchorPane>
</content>
</Tab>
<Tab text="%common.tool.debug.httpTool.tab.responseHeader">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<VirtualizedScrollPane AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<content>
<InformationArea fx:id="ResponseHeaderTextArea"/>
</content>
</VirtualizedScrollPane>
</children>
</AnchorPane>
</content>
</Tab>
</tabs>
<BorderPane.margin>
<Insets left="10.0" top="10.0"/>
</BorderPane.margin>
</TabPane>
</center>
</BorderPane>
</children>
</AnchorPane>
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,28 @@ common.tool.image.iconTool.sampleName=Icon Tool
common.tool.image.iconTool.sampleDesc=It can quickly generate icons of various sizes in batches, including IOS and Android icons, including adding watermarks, rounded corner settings and other functions.
common.tool.debug.scanPortTool.sampleName=ScanPortTool
common.tool.debug.scanPortTool.sampleDesc=The port scanning tool supports multi-IP and multi-port batch inspection, common port query, resolves the IP address corresponding to the domain name, and obtains the local external network IP function.
common.tool.debug.httpTool.sampleName=Http Tool
common.tool.debug.httpTool.sampleDesc=HTTP debugging tool.
common.tool.debug.httpTool.menu.compressJson=Compress JSON
common.tool.debug.httpTool.menu.formatJson=Format JSON
common.tool.debug.httpTool.error.format=Formatting error:
common.tool.debug.httpTool.error.emptyUrl=Please enter a URL!
common.tool.debug.httpTool.error.request=Request failed
common.tool.debug.httpTool.menu.copyRow=Copy selected row
common.tool.debug.httpTool.menu.deleteRow=Delete selected row
common.tool.debug.httpTool.menu.deleteAll=Delete all rows
common.tool.debug.httpTool.button.send=Send
common.tool.debug.httpTool.checkbox.paramsData=Include parameters
common.tool.debug.httpTool.label.url=URL
common.tool.debug.httpTool.prompt.url=Enter URL
common.tool.debug.httpTool.label.method=Method
common.tool.debug.httpTool.button.toBrowser=Open in Browser
common.tool.debug.httpTool.checkbox.string=String
common.tool.debug.httpTool.button.add=Add
common.tool.debug.httpTool.checkbox.header=Request Header
common.tool.debug.httpTool.checkbox.cookie=Request Cookie
common.tool.debug.httpTool.column.paramName=Parameter\nName
common.tool.debug.httpTool.column.paramValue=Parameter\nValue
common.tool.debug.httpTool.column.remark=Remark
common.tool.debug.httpTool.tab.responseContent=Response Content
common.tool.debug.httpTool.tab.responseHeader=Response Header
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,28 @@ common.tool.image.iconTool.sampleName=\u30A2\u30A4\u30B3\u30F3\u30C4\u30FC\u30EB
common.tool.image.iconTool.sampleDesc=\u900F\u304B\u3057\u306E\u8FFD\u52A0\u3001\u89D2\u4E38\u8A2D\u5B9A\u3001\u305D\u306E\u4ED6\u306E\u6A5F\u80FD\u3092\u542B\u3081\u3001IOS \u3084 Android \u30A2\u30A4\u30B3\u30F3\u3092\u542B\u3080\u3055\u307E\u3056\u307E\u306A\u30B5\u30A4\u30BA\u306E\u30A2\u30A4\u30B3\u30F3\u3092\u30D0\u30C3\u30C1\u3067\u3059\u3070\u3084\u304F\u751F\u6210\u3067\u304D\u307E\u3059\u3002
common.tool.debug.scanPortTool.sampleName=\u30B9\u30AD\u30E3\u30F3\u30DD\u30FC\u30C8\u30C4\u30FC\u30EB
common.tool.debug.scanPortTool.sampleDesc=\u30DD\u30FC\u30C8 \u30B9\u30AD\u30E3\u30F3 \u30C4\u30FC\u30EB\u306F\u3001\u30DE\u30EB\u30C1 IP \u304A\u3088\u3073\u30DE\u30EB\u30C1\u30DD\u30FC\u30C8\u306E\u30D0\u30C3\u30C1\u691C\u67FB\u3001\u5171\u901A\u30DD\u30FC\u30C8 \u30AF\u30A8\u30EA\u3092\u30B5\u30DD\u30FC\u30C8\u3057\u3001\u30C9\u30E1\u30A4\u30F3\u540D\u306B\u5BFE\u5FDC\u3059\u308B IP \u30A2\u30C9\u30EC\u30B9\u3092\u89E3\u6C7A\u3057\u3001\u30ED\u30FC\u30AB\u30EB\u5916\u90E8\u30CD\u30C3\u30C8\u30EF\u30FC\u30AF IP \u6A5F\u80FD\u3092\u53D6\u5F97\u3057\u307E\u3059\u3002
common.tool.debug.httpTool.sampleName=Http \u30C4\u30FC\u30EB
common.tool.debug.httpTool.sampleDesc=HTTP\u30C7\u30D0\u30C3\u30B0\u30C4\u30FC\u30EB\u3002
common.tool.debug.httpTool.menu.compressJson=JSON\u306E\u5727\u7E2E
common.tool.debug.httpTool.menu.formatJson=JSON\u306E\u66F8\u5F0F
common.tool.debug.httpTool.error.format=\u66F8\u5F0F\u30A8\u30E9\u30FC\uFF1A
common.tool.debug.httpTool.error.emptyUrl=\u30A6\u30A7\u30D6\u30B5\u30A4\u30C8\u306B\u304A\u5165\u308A\u304F\u3060\u3055\u3044\uFF01
common.tool.debug.httpTool.error.request=\u30EA\u30AF\u30A8\u30B9\u30C8\u5931\u6557
common.tool.debug.httpTool.menu.copyRow=\u9078\u629E\u3057\u305F\u884C\u3092\u30B3\u30D4\u30FC
common.tool.debug.httpTool.menu.deleteRow=\u9078\u629E\u884C\u306E\u524A\u9664
common.tool.debug.httpTool.menu.deleteAll=\u5168\u884C\u524A\u9664
common.tool.debug.httpTool.button.send=\u9001\u4FE1
common.tool.debug.httpTool.checkbox.paramsData=\u30D1\u30E9\u30E1\u30FC\u30BF\u3092\u542B\u3080
common.tool.debug.httpTool.label.url=URL
common.tool.debug.httpTool.prompt.url=URL\u3092\u5165\u529B\u3057\u3066\u4E0B\u3055\u3044
common.tool.debug.httpTool.label.method=\u30EA\u30AF\u30A8\u30B9\u30C8\u65B9\u6CD5
common.tool.debug.httpTool.button.toBrowser=\u30D6\u30E9\u30A6\u30B6\u3067\u958B\u304F
common.tool.debug.httpTool.checkbox.string=\u30B9\u30C8\u30EA\u30F3\u30B0
common.tool.debug.httpTool.button.add=\u5897\u52A0
common.tool.debug.httpTool.checkbox.header=\u30EA\u30AF\u30A8\u30B9\u30C8\u30FB\u30D8\u30C3\u30C0
common.tool.debug.httpTool.checkbox.cookie=\u30AF\u30C3\u30AD\u30FC\u306E\u30EA\u30AF\u30A8\u30B9\u30C8
common.tool.debug.httpTool.column.paramName=\u30D1\u30E9\u30E1\u30FC\u30BF\u540D
common.tool.debug.httpTool.column.paramValue=\u30D1\u30E9\u30E1\u30FC\u30BF\u5024
common.tool.debug.httpTool.column.remark=\u5099\u8003
common.tool.debug.httpTool.tab.responseContent=\u56DE\u7B54\u5185\u5BB9
common.tool.debug.httpTool.tab.responseHeader=\u5FDC\u7B54\u30D8\u30C3\u30C0\u30FC
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,28 @@ common.tool.image.iconTool.sampleName=\u56FE\u6807\u751F\u6210\u5DE5\u5177
common.tool.image.iconTool.sampleDesc=\u53EF\u5FEB\u901F\u6279\u91CF\u751F\u6210\u5404\u79CD\u5927\u5C0F\u7684\u56FE\u6807,\u5305\u62ECIOS\u548CAndroid\u56FE\u6807\uFF0C\u5305\u62EC\u6DFB\u52A0\u6C34\u5370\uFF0C\u5706\u89D2\u8BBE\u7F6E\u7B49\u529F\u80FD\u3002
common.tool.debug.scanPortTool.sampleName=\u7AEF\u53E3\u626B\u63CF\u5DE5\u5177
common.tool.debug.scanPortTool.sampleDesc=\u7AEF\u53E3\u626B\u63CF\u5DE5\u5177\uFF0C\u652F\u6301\u591Aip\u3001\u591A\u7AEF\u53E3\u6279\u91CF\u68C0\u67E5\uFF0C\u5E38\u7528\u7AEF\u53E3\u67E5\u8BE2\uFF0C\u89E3\u6790\u57DF\u540D\u5BF9\u5E94ip\u5730\u5740\uFF0C\u83B7\u53D6\u672C\u673A\u5916\u7F51ip\u529F\u80FD\u3002
common.tool.debug.httpTool.sampleName=Http\u5DE5\u5177
common.tool.debug.httpTool.sampleDesc=HTTP\u8C03\u8BD5\u5DE5\u5177\u3002
common.tool.debug.httpTool.menu.compressJson=\u538B\u7F29JSON
common.tool.debug.httpTool.menu.formatJson=\u683C\u5F0F\u5316JSON
common.tool.debug.httpTool.error.format=\u683C\u5F0F\u5316\u9519\u8BEF\uFF1A
common.tool.debug.httpTool.error.emptyUrl=\u8BF7\u8F93\u5165\u7F51\u7AD9\uFF01
common.tool.debug.httpTool.error.request=\u8BF7\u6C42\u5931\u8D25
common.tool.debug.httpTool.menu.copyRow=\u590D\u5236\u9009\u4E2D\u884C
common.tool.debug.httpTool.menu.deleteRow=\u5220\u9664\u9009\u4E2D\u884C
common.tool.debug.httpTool.menu.deleteAll=\u5220\u9664\u6240\u6709\u884C
common.tool.debug.httpTool.button.send=\u53D1\u9001
common.tool.debug.httpTool.checkbox.paramsData=\u5305\u542B\u53C2\u6570
common.tool.debug.httpTool.label.url=\u7F51\u5740
common.tool.debug.httpTool.prompt.url=\u8BF7\u8F93\u5165\u7F51\u5740
common.tool.debug.httpTool.label.method=\u8BF7\u6C42\u65B9\u6CD5
common.tool.debug.httpTool.button.toBrowser=\u5728\u6D4F\u89C8\u5668\u4E2D\u6253\u5F00
common.tool.debug.httpTool.checkbox.string=\u5B57\u7B26\u4E32
common.tool.debug.httpTool.button.add=\u6DFB\u52A0
common.tool.debug.httpTool.checkbox.header=\u8BF7\u6C42\u5934
common.tool.debug.httpTool.checkbox.cookie=\u8BF7\u6C42Cookie
common.tool.debug.httpTool.column.paramName=\u53C2\u6570\u540D
common.tool.debug.httpTool.column.paramValue=\u53C2\u6570\u503C
common.tool.debug.httpTool.column.remark=\u5907\u6CE8
common.tool.debug.httpTool.tab.responseContent=\u54CD\u5E94\u5185\u5BB9
common.tool.debug.httpTool.tab.responseHeader=\u54CD\u5E94\u5934\u90E8
Loading
Loading