ワンクリックで
curl-request-tracker
Pattern for adding request tracking and curl command generation to HTTP client wrapper classes
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Pattern for adding request tracking and curl command generation to HTTP client wrapper classes
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
| name | curl-request-tracker |
| description | Pattern for adding request tracking and curl command generation to HTTP client wrapper classes |
| source | auto-skill |
| extracted_at | 2026-07-09T04:55:02.535Z |
When an HTTP client wrapper class needs debugging/diagnostic capability to reproduce the last request as a curl command.
Add private fields to capture the last request's method and body:
private String _LastMethod;
private String _LastBody;
The URL is typically already tracked (e.g., _LastUrl).
private void recordLastRequest(String method, String body) {
this._LastMethod = method;
this._LastBody = body;
}
Call recordLastRequest(method, body) at the top of each public HTTP method (doGet, doPost, doPut, doDelete, doPatch, downloadData, doUpload, etc.), before any network I/O. This ensures tracking even if the request fails.
String body overloads: pass the body directlyMap<String, String> form param overloads: encode to key=value&... format firstbyte[] overloads: record as "<binary N bytes>""<multipart upload>"createLastCurl()Build the curl command with \\\n (backslash + newline + 2 spaces) for line continuation:
curl -X METHOD \
'URL' \
-H 'User-Agent: ...' \
-H 'Header: value' \
-H 'Cookie: ...' \
--proxy 'scheme://host:port' \
-d 'body'
Key details:
' → '\''-d only if body is non-null and non-emptynull if no request has been made yetprivate static String escapeShell(String value) {
if (value == null) return "";
return value.replace("'", "'\\''");
}
private String encodeFormData(Map<String, String> vals) {
if (vals == null || vals.isEmpty()) return null;
StringBuilder sb = new StringBuilder();
String charset = this._Encode == null ? "UTF-8" : this._Encode;
for (Map.Entry<String, String> entry : vals.entrySet()) {
if (sb.length() > 0) sb.append("&");
sb.append(URLEncoder.encode(entry.getKey(), charset))
.append("=")
.append(URLEncoder.encode(entry.getValue(), charset));
}
return sb.toString();
}
HttpServer (from com.sun.net.httpserver.HttpServer) to avoid real network calls-X METHOD-d flag-H / --proxy\\\n)When applying to multiple branches (e.g., main vs jdk17 with different HTTP backends):
createLastCurl() method are identical across branchesgit stash workflow: stash main changes → checkout target branch → apply same pattern → stash → checkout main → pop