### Install Reqable on Mac using Homebrew
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/getting-started/index.mdx
This command installs Reqable on macOS using the Homebrew package manager. It assumes Homebrew is already installed and configured on the system.
```shell
brew install reqable
```
--------------------------------
### Install Reqable on Linux using apt
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/getting-started/index.mdx
This command installs the Reqable application on Debian-based Linux distributions. It requires the `reqable-app-linux-x86_64.deb` file to be present and assumes the system has the GTK library installed.
```shell
sudo apt install reqable-app-linux-x86_64.deb
```
--------------------------------
### Refactor Android Certificate Installation Guide
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/changelogs/windows/index.md
Refactored the guide for installing CA certificates on Android devices. This aims to provide clearer, step-by-step instructions for users.
```markdown
# Installing CA Certificate on Android
## Step 1: Obtain the Certificate...
## Step 2: Transfer Certificate to Device...
## Step 3: Install Certificate via Settings...
```
--------------------------------
### Print App Information
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/capture/24_addons.md
Provides an example of how to access and print information about the running application, including its name, ID, and installation path.
```python
def onRequest(context, response):
# Print app information
print(context.app.name)
print(context.app.id)
print(context.app.path)
# Done
return request
```
--------------------------------
### Configure Android Network Security Config
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/getting-started/installation/index.md
This snippet demonstrates how to create a `network_security_config.xml` file to trust user certificates in Android. It also shows how to reference this configuration in the `AndroidManifest.xml` for the application.
```xml
```
```xml
...
```
--------------------------------
### Handling Firefox Unsafe Website Prompt (Reqable)
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/faq/windows.md
This explains how to resolve the 'unsafe website' prompt in Firefox when using Reqable, due to Firefox's use of its own CA Store. It directs users to follow Reqable's specific Firefox certificate installation guide.
```plaintext
Install Reqable's CA certificate in Firefox's certificate manager.
```
--------------------------------
### Fix: Application Startup Failure
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/changelogs/windows/index.md
Addresses an issue that caused the application to fail to start in certain scenarios.
```General
🐞 [FIX] The bug that the application cannot start in some cases.
```
--------------------------------
### Introduce script templates
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/changelogs/ios/index.md
Adds the functionality to use script templates, providing pre-defined structures and examples for various API testing scenarios. This accelerates script creation.
```text
🚀 [NEW] Introduce script templates.
```
--------------------------------
### Support for HTTP Request Method and Status Code to MDN (Example)
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/changelogs/android/index.md
Features the ability to link HTTP request methods (like GET, POST) and status codes (like 200, 404) directly to their documentation on MDN (Mozilla Developer Network). This enhances usability by providing quick access to relevant information.
```plaintext
// Conceptual UI element that links to MDN
function createStatusLink(statusCode) {
const mdnBaseUrl = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/';
const link = document.createElement('a');
link.href = mdnBaseUrl + statusCode;
link.textContent = statusCode;
link.target = '_blank'; // Open in new tab
return link;
}
function createMethodLink(method) {
const mdnBaseUrl = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/';
const link = document.createElement('a');
link.href = mdnBaseUrl + method.toLowerCase();
link.textContent = method;
link.target = '_blank';
return link;
}
// Example usage:
// const statusElement = document.getElementById('status-code');
// statusElement.appendChild(createStatusLink(200));
// const methodElement = document.getElementById('request-method');
// methodElement.appendChild(createMethodLink('POST'));
```
--------------------------------
### Example Redirection in Reqable
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/capture/26_rewrite.mdx
Demonstrates how to set up a URL redirection rule in Reqable. It shows how an original URL like 'https://hello.com/foo/bar/ok?abc=123' can be redirected to 'https://world.com/new/*' and the resulting actual redirected URL.
```text
Original URL: https://hello.com/foo/bar/ok?abc=123
Redirected to: https://world.com/new/*
Actual Redirected URL: https://world.com/new/foo/bar/ok?abc=123
```
--------------------------------
### Add Reqable User Certificate Dependency to Gradle
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/getting-started/installation/index.md
This snippet shows how to add the Reqable user certificate trust dependency to your Android app's `build.gradle` file. This is the recommended method for automatically integrating the network security configuration for debug builds.
```groovy
dependencies {
debugImplementation("com.reqable.android:user-certificate-trust:1.0.0")
}
```
--------------------------------
### Magisk Module for CA Certificate Installation
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/changelogs/windows/index.md
Introduces automatic generation of a Magisk module to install CA certificates. This simplifies the process of trusting custom certificates on Android devices using Magisk.
```shell
magisk --install-module path/to/your/ca.zip
```
--------------------------------
### Configuring System Proxy for Reqable (Windows)
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/faq/windows.md
This section outlines the manual steps to verify system proxy settings in Windows to ensure Reqable can capture traffic. It involves checking the 'Manual proxy setup' in Windows Settings.
```plaintext
Windows menu -> Settings -> Network & Internet -> Proxy -> Manual proxy setup
```
--------------------------------
### Parameter and Header Highlighting
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/changelogs/windows/index.md
Fixes a bug where parameters and headers starting with `_` were not highlighted. This ensures consistent highlighting for all request parameters and headers.
```text
_private_param
```
--------------------------------
### App API
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/capture/24_addons.md
Provides information about the application context, including app name, ID, and installation path.
```APIDOC
## App
### Description
Provides access to information about the application that initiated the request.
### Variables
- **name** (str) - The name of the application.
- **id** (str) - The unique identifier of the application (e.g., `bundleId` for macOS, `packageName` for Android). Returns `None` if not detected.
- **path** (str) - The installation path of the application.
### Code Example
```python
def onRequest(context, response):
# Print app information
print(context.app.name)
print(context.app.id)
print(context.app.path)
# Done
return request
```
```
--------------------------------
### Fix: Root Certificate Installation
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/changelogs/macos/index.md
Addresses an issue where the root certificate could not be installed.
```markdown
- 🐞 [FIX] The bug that it is unable to install root certificate.
```
--------------------------------
### Bookmark Filtering Example
Source: https://github.com/reqable/reqable-docs/blob/master/zh-CN/capture/04_explorer.md
This example demonstrates how bookmarks can be used to filter requests based on URL paths. If a bookmark is a domain, all requests under that domain are filtered. If it's a path, only requests matching that path and its subdirectories are shown.
```text
https://reqable.com/zh-CN/img/logo.svg
https://reqable.com/zh-CN/assets/css/styles.7bbae746.css
```
--------------------------------
### CA Root Certificate Installation Status Daemon
Source: https://github.com/reqable/reqable-docs/blob/master/zh-CN/changelogs/macos/index.md
Uses a resident daemon process to check the installation status of CA root certificates. This ensures accurate and up-to-date information on certificate trust.
```text
A resident daemon process is used to check CA root certificate installation status.
```
--------------------------------
### Handle API Testing Environment Variables (Example)
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/changelogs/android/index.md
Illustrates a conceptual approach to managing environment variables within an API testing context. This is important for parameterizing requests, such as authentication credentials or base URLs, making tests more flexible and maintainable.
```plaintext
# Example configuration file (e.g., config.json)
{
"environment": "staging",
"baseUrl": "https://api.staging.example.com",
"apiKey": "YOUR_STAGING_API_KEY"
}
# Example usage in a test script (pseudo-code)
loadConfig('config.json');
const url = environment.baseUrl + '/users';
const headers = {
'Authorization': 'Bearer ' + environment.apiKey,
'Content-Type': 'application/json'
};
// Make request using url and headers
```
--------------------------------
### Automatic Magisk Module for CA Certificate Installation
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/changelogs/linux/index.md
Provides an automated way to generate a Magisk module for installing the Reqable CA certificate on Android devices. This simplifies the process of setting up system-wide HTTPS interception.
```bash
# Conceptual script for generating a Magisk module
# Assumes cert.pem contains the Reqable CA certificate
# Create module directory structure
mkdir -p magisk-module/META-INF
mkdir -p magisk-module/system/etc/security/cacerts
# Copy the certificate
cp cert.pem magisk-module/system/etc/security/cacerts/reqable.pem
# Create module.prop file
echo "id=reqable-ca"
echo "name=Reqable CA Certificate"
echo "version=v1.0"
echo "versionCode=1"
echo "author=Reqable"
echo "description=Installs Reqable CA certificate for system-wide HTTPS interception."
> magisk-module/module.prop
# Zip the module (requires zip command)
# zip -r reqable-ca-v1.0.zip magisk-module
```
--------------------------------
### Configuring Secondary Proxy for Geo-Restricted Sites (Android)
Source: https://github.com/reqable/reqable-docs/blob/master/zh-CN/faq/android.md
This guide explains how to access geo-restricted websites using Reqable by setting up a secondary proxy. It involves installing and running a proxy tool on the computer, configuring Reqable to use this tool as a secondary proxy, and then connecting the phone to Reqable.
```text
Install and run a scientific internet access tool on your computer.
Configure Reqable on your computer to use the tool as a [secondary proxy](../capture/proxy#secondary).
Connect your phone to Reqable on the computer using the QR code (collaborative mode).
```
--------------------------------
### Handle Form Data Decoding with '+' to Space (Example)
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/changelogs/android/index.md
Describes a common issue where '+' characters in form data are incorrectly decoded as spaces. This example outlines the problem and suggests a solution, typically involving custom decoding logic or ensuring the library handles it correctly.
```plaintext
# Problem: URL encoded data like 'search=hello+world'
# Incorrect decoding results in: 'search=hello world'
# Correct decoding should preserve the '+' if it's meant to be literal,
# or interpret it as a space only if it's part of standard application/x-www-form-urlencoded.
# Solution Idea: Implement custom decoding or use a robust library
def custom_decode_form_data(data):
decoded = {}
for key, value in data.items():
# Replace '+' with space only if it's not intended to be literal '+'
# This logic can be complex depending on the encoding context
decoded[key] = value.replace('+', ' ')
return decoded
# Assume 'raw_form_data' is received
# processed_data = custom_decode_form_data(parse_raw_form_data(raw_form_data))
```
--------------------------------
### Handle Basic Auth Environment Variable Bug (Example)
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/changelogs/android/index.md
Identifies an issue where environment variables used in Basic Authentication are not functioning correctly. This implies a problem in how the application resolves or substitutes these variables when constructing authentication headers.
```plaintext
# Conceptual example of Basic Auth with environment variables
import base64
import os
username = os.environ.get('API_USERNAME')
password = os.environ.get('API_PASSWORD')
if username and password:
credentials = f"{username}:{password}"
encoded_credentials = base64.b64encode(credentials.encode()).decode()
headers = {
'Authorization': f'Basic {encoded_credentials}'
}
# Make API request with these headers
# print(f"Sending request with headers: {headers}")
else:
print("Error: API_USERNAME or API_PASSWORD environment variables not set.")
# The bug might be in how 'os.environ.get' is called or how the
# resulting string is used in the 'Authorization' header format.
```
--------------------------------
### Response Modification Example
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/capture/24_addons.md
An example demonstrating how to modify JSON response data.
```APIDOC
## Example 1: Modifying JSON Response Data
### Description
This example shows how to modify a specific field within a JSON response.
### Original Response Body Example
```json
{
"code": 10000,
"message": "ok",
"content": {
"version": "1.0.0",
"platform": "windows"
}
}
```
### Modification Goal
Change the value of `version` to `2.0.0`.
### Code Example
```python
from reqable import *
def onRequest(context, request):
# Done
return request
def onResponse(context, response):
# Jsonify the response body
response.body.jsonify()
# Modify the version value in the dictionary
response.body['content']['version'] = '2.0.0'
# Done
return response
```
```
--------------------------------
### Bookmark Filtering Example
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/capture/04_explorer.md
Demonstrates how bookmarks can filter traffic based on URL structure. Requests under a specific path or any request within a domain are filtered.
```text
https://reqable.com/en-US/img/logo.svg
https://reqable.com/en-US/assets/css/styles.7bbae746.css
```
--------------------------------
### Set Request Highlight Color
Source: https://github.com/reqable/reqable-docs/blob/master/zh-CN/capture/24_addons.md
Demonstrates how to apply visual highlighting to requests based on predefined colors. This example sets the request highlight to red.
```python
def onRequest(context, response):
# 设置请求红色高亮
context.highlight = Highlight.red
# Done
return request
```
--------------------------------
### C# HttpClient and RestSharp Code Snippet
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/changelogs/macos/index.md
Provides code examples for making HTTP requests using C# with HttpClient and RestSharp libraries. This snippet is useful for developers integrating with Reqable's API testing or exporting functionality.
```csharp
// Example for C# HttpClient
using System.Net.Http;
using System.Threading.Tasks;
public class HttpClientExample {
public static async Task MakeRequest() {
using (var client = new HttpClient()) {
var response = await client.GetAsync("http://example.com");
response.EnsureSuccessStatusCode();
var content = await response.Content.ReadAsStringAsync();
// Process content
}
}
}
// Example for C# RestSharp
using RestSharp;
public class RestSharpExample {
public static void MakeRequest() {
var client = new RestClient("http://example.com");
var request = new RestRequest("resource", Method.GET);
var response = client.Execute(request);
// Process response.Content
}
}
```
--------------------------------
### Python Server Example for Reqable Report Server
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/capture/30_report-server.md
A Python server example demonstrating how to receive and process data uploaded by Reqable's Report Server. This server is designed to parse incoming HTTP Archive (HAR) format data, which is sent via POST requests.
```python
from flask import Flask, request, jsonify
import json
app = Flask(__name__)
@app.route('/', methods=['POST'])
def receive_report():
# Check if the request content type is JSON
if request.content_type != 'application/json':
return jsonify({'error': 'Invalid content type. Expected application/json.'}), 415
try:
# Load the HAR data from the request body
har_data = request.get_json()
# Process the HAR data (example: print the number of entries)
if 'log' in har_data and 'entries' in har_data['log']:
num_entries = len(har_data['log']['entries'])
print(f"Received {num_entries} entries.")
# You can further process each entry here
# for entry in har_data['log']['entries']:
# print(f" - URL: {entry['request']['url']}")
else:
print("Received data does not contain expected HAR log structure.")
print(json.dumps(har_data, indent=2))
# Return a success response
return jsonify({'message': 'Data received successfully'}), 200
except Exception as e:
print(f"Error processing request: {e}")
return jsonify({'error': 'Failed to process data'}), 500
if __name__ == '__main__':
# Run the Flask app
# For production, use a proper WSGI server like Gunicorn
app.run(host='0.0.0.0', port=5000)
```
--------------------------------
### Automatic MD5 Signature for Request Parameters
Source: https://github.com/reqable/reqable-docs/blob/master/zh-CN/capture/24_addons.md
Example script to automatically sign request parameters using MD5.
```APIDOC
## Automatic MD5 Signature for Request Parameters
### Description
This example shows how to automatically generate an MD5 signature for request parameters and add it to the request headers.
### Script
```python
from reqable import *
import hashlib
def onRequest(context, request):
# Sort query parameters
request.queries = sorted(request.queries)
# Concatenate query data
text = request.queries.concat()
# Use MD5 algorithm for signing
algorithm = hashlib.md5()
# Calculate the signature of the string
algorithm.update(text.encode(encoding='UTF-8'))
signature = algorithm.hexdigest()
# Add the signature to the request headers
request.headers['signature'] = signature
# Done
return request
def onResponse(context, response):
# Done
return response
```
```
--------------------------------
### Fix: Certificate Recognition
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/changelogs/windows/index.md
Addresses a bug where the root certificate installed for the current user was not being recognized by the application.
```General
🐞 [FIX] The bug that the root certificate installed to the current user cannot be recognized.
```
--------------------------------
### Automatic Image Saving
Source: https://github.com/reqable/reqable-docs/blob/master/zh-CN/capture/24_addons.md
Example script to automatically save image responses to a specified directory.
```APIDOC
## Automatic Image Saving
### Description
This example provides a script to automatically save image responses to a local directory, deriving the file extension from the MIME type.
### Script
```python
from reqable import *
from mimetypes import guess_extension
import datetime
import os
def onRequest(context, request):
return request
def onResponse(context, response):
# Check MIME type, skip if not an image
mime = response.mime
if mime == None:
return response
maintype, subtype = mime.split('/')
if not maintype == 'image':
return response
# Save the image to the specified directory with a timestamped filename and inferred extension
dir = '/Users/megatronking/Downloads/reqable/'
os.makedirs(dir, exist_ok=True)
name = datetime.datetime.now().strftime("%H%M%S%f")
ext = guess_extension(mime)
image = os.path.join(dir, name + ext)
# Write the response body to the file
print(f'Saving image {image}')
response.body.writeFile(image)
# Done
return response
```
```
--------------------------------
### API and Traffic Code Snippets
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/changelogs/macos/index.md
Reqable now includes code snippets for API and traffic management. This feature likely allows users to generate code examples for interacting with APIs or replicating traffic requests.
```javascript
// Example JavaScript snippet for making an API request
fetch('https://api.example.com/users', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_TOKEN'
}
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
```
```python
# Example Python snippet using requests library
import requests
url = 'https://api.example.com/users'
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_TOKEN'
}
response = requests.get(url, headers=headers)
if response.status_code == 200:
print(response.json())
else:
print(f'Error: {response.status_code}')
```
--------------------------------
### Configuring SSL Bypass Rule Example
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/capture/12_ssl.md
Demonstrates the use of wildcard characters in domain names for SSL bypass rules. Requests matching the pattern will bypass SSL decryption.
```plaintext
*.apple.com
```
--------------------------------
### Generate MD5 Signature for Request Parameters
Source: https://github.com/reqable/reqable-docs/blob/master/zh-CN/capture/24_addons.md
This example automatically adds an 'signature' header to requests by calculating an MD5 hash of the sorted query parameters. It utilizes Python's hashlib for MD5 calculation.
```python
from reqable import *
import hashlib
def onRequest(context, request):
# 对query列表进行排序
request.queries = sorted(request.queries)
# 拼接query数据
text = request.queries.concat()
# 选用md5算法进行签名
algorithm = hashlib.md5()
# 计算字符串的签名
algorithm.update(text.encode(encoding='UTF-8'))
signature = algorithm.hexdigest()
# 签名加到请求头中
request.headers['signature'] = signature
# Done
return request
def onResponse(context, response):
# Done
return response
```
--------------------------------
### Set Highlight for Requests
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/capture/24_addons.md
Demonstrates how to apply highlighting to requests using the Highlight enum. This example sets the request highlight to red.
```python
def onRequest(context, response):
# Set request read highlight
context.highlight = Highlight.red
# Done
return request
```
--------------------------------
### Reqable Python Scripting API Context Example
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/capture/24_addons.md
Demonstrates how to use the Context object in Python to access request details such as URL, scheme, host, port, connection ID, and timestamps. It also shows how to read and write environment variables and share data between onRequest and onResponse functions.
```python
def onRequest(context, request):
# Print url, for example: https://reqable.com/
print(context.url)
# Print scheme, for example: https
print(context.scheme)
# Print host, for example: reqable.com
print(context.host)
# Print port number, for example: 443
print(context.port)
# Print connection ID, for example: 1
print(context.cid)
# Print TCP connection timestamp, for example: 1686711219444
print(context.ctime)
# Print HTTP session ID, for example: 1
print(context.sid)
# Print HTTP session start timestamp, for example: 1686711224132
print(context.stime)
# Get an environment variable
print(context.env['foo'])
print(context.env['$timestamp'])
# Write an environment variable
# The currently activated custom environment is written first, and if there is no activated environment, the global environment is written.
context.env['foo'] = 'bar'
# Set shared value
context.shared = 'Hello'
# Done
return request
def onResponse(context, response):
# Print shared value, output: Hello
print(context.shared)
return response
```
--------------------------------
### QR Code Display Change
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/changelogs/windows/index.md
Changes the display of the certificate link QR code from click-to-display to mouse-hover display. This offers a quicker way to access the QR code for certificate installation.
```text
Scan QR code on hover
```
--------------------------------
### Urlencode Request Body Example
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/rest/03_body.md
Demonstrates the format for a Urlencode request body, which consists of key-value pairs separated by '&'. This format is commonly used for form submissions.
```text
foo=bar&hello=reqable
```
--------------------------------
### New: Proxy Helper Tool
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/changelogs/macos/index.md
Introduces a new proxy helper tool that replaces the `networksetup CLI` for configuring system proxies.
```markdown
- 🚀 [NEW] Introduce the proxy helper tool, which replaces `networksetup CLI` to configure system proxy.
```
--------------------------------
### Add Code Snippet for API and Traffic (v1.2.0)
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/changelogs/windows/index.md
Includes a code snippet specifically for API and traffic-related functionalities. This provides developers with a direct example of how to interact with or utilize these features.
```javascript
// Example JavaScript code for API and Traffic integration
// This snippet provides a practical example of how to work with API and traffic features within Reqable.
// It serves as a starting point for developers integrating Reqable into their projects.
```
--------------------------------
### Import Postman/Hoppscotch/ApiPost/Apifox Collections
Source: https://github.com/reqable/reqable-docs/blob/master/zh-CN/changelogs/macos/index.md
Adds the ability to import API collections from popular tools like Postman, Hoppscotch, ApiPost, and Apifox. This allows users to migrate their existing API testing setups to Reqable.
```text
Support for importing API collections from Postman, Hoppscotch, ApiPost, and Apifox has been added.
```
--------------------------------
### Manage HTTP Headers in Python
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/capture/24_addons.md
Provides examples of managing HTTP headers using Python. Covers functions for counting, iterating, adding, removing, clearing, updating, and retrieving header values, and accessing headers by index.
```python
def onRequest(context, request):
# Print the count of headers
print(len(request.headers))
# Iterate the header list
for header in request.headers:
print(header)
# Add a new header
request.headers.add('foo', 'bar')
# Remove the header named `foo`
request.headers.remove('foo')
# Remove all headers
request.headers.clear()
# Update the header, if it does not exist, it will be added automatically.
request.headers['foo'] = 'bar'
# Print the header value, for example: bar
print(request.headers['foo'])
# Print the header at the specified index position, for example: `foo: bar`
print(request.headers[0])
# Done
return request
```
--------------------------------
### Generate C# HttpClient Code Snippet
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/changelogs/android/index.md
Provides a C# code snippet demonstrating how to make an HTTP request using the HttpClient class. This is useful for converting network requests into runnable C# code for integration into .NET applications. Includes basic setup and request execution.
```csharp
using System.Net.Http;
using System.Threading.Tasks;
public class HttpClientExample
{
public static async Task MakeRequestAsync()
{
using (HttpClient client = new HttpClient())
{
HttpResponseMessage response = await client.GetAsync("http://example.com");
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
System.Console.WriteLine(responseBody);
}
}
}
```
--------------------------------
### Window Size and Content Rendering Fix
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/changelogs/windows/index.md
Fixes bugs related to incorrect window size and content rendering area, particularly under multiple monitor setups. This ensures a consistent and accurate display across different screen configurations.
```text
UI Element Layout Adjustment
```
--------------------------------
### Support for MITM Handling of 100 Continue (Example)
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/changelogs/android/index.md
Addresses a bug where a Man-in-the-Middle (MITM) proxy does not correctly handle `100 Continue` responses. This is important for clients that send large request bodies, as `100 Continue` allows the server to signal that it accepts the request headers before the body is sent.
```plaintext
# Conceptual logic for a MITM proxy handling 'Expect: 100-continue'
def handle_request(client_socket):
request_headers, client_socket = read_request_headers(client_socket)
if 'Expect' in request_headers and request_headers['Expect'] == '100-continue':
# Decide whether to send 100 Continue or reject immediately
if should_continue(request_headers):
send_100_continue(client_socket)
# Now wait for the request body
request_body, client_socket = read_request_body(client_socket)
# Forward request (headers + body) to the server
server_response = forward_to_server(request_headers, request_body)
# Process server response
else:
send_417_expectation_failed(client_socket)
else:
# No 'Expect' header, process normally
request_body, client_socket = read_request_body(client_socket)
server_response = forward_to_server(request_headers, request_body)
# Process server response
def should_continue(headers):
# Implement logic to decide if '100 Continue' should be sent
# e.g., based on request method, headers, or preliminary checks
return True
def send_100_continue(socket):
socket.sendall(b'HTTP/1.1 100 Continue\r\n\r\n')
def send_417_expectation_failed(socket):
socket.sendall(b'HTTP/1.1 417 Expectation Failed\r\nContent-Length: 0\r\n\r\n')
# The bug likely lies in the 'should_continue' logic or the
# correct sending/handling of the 100 Continue response.
```
--------------------------------
### Reqable日志文件目录
Source: https://github.com/reqable/reqable-docs/blob/master/zh-CN/faq/windows.md
提供Reqable应用程序在Windows系统下的日志文件存储路径。日志文件对于排查问题和了解应用程序运行状态非常重要。
```text
C:\Users\xxx\AppData\Roaming\Reqable\log
```
--------------------------------
### Reqable缓存目录路径
Source: https://github.com/reqable/reqable-docs/blob/master/zh-CN/faq/windows.md
显示Reqable应用程序在Windows系统下的缓存文件存储路径。此路径用于查找和管理Reqable的缓存数据。
```text
C:\Users\xxx\AppData\Roaming\Reqable
```
--------------------------------
### 配置回环代理
Source: https://github.com/reqable/reqable-docs/blob/master/zh-CN/faq/windows.md
说明如何检查和配置Reqable的回环代理设置,以解决无法捕获localhost流量的问题。这涉及到Reqable的代理菜单和系统代理设置中的排除项。
```text
Windows菜单 -> 设置 -> 网络和Internet -> 代理 -> 手动设置代理 -> 请勿对以下列条目开头的地址使用代理服务器
```
--------------------------------
### Python脚本操作环境变量
Source: https://github.com/reqable/reqable-docs/blob/master/zh-CN/environment/practice/index.md
在Reqable的Python脚本中,可以通过`context.env`字典来读取和写入环境变量。写入变量时,如果未激活用户环境,则写入全局环境;否则写入当前激活的环境,并覆盖同名变量。
```python
print(context.env['username'])
```
```python
context.env['username'] = 'reqable'
```
--------------------------------
### API请求环境变量引用
Source: https://github.com/reqable/reqable-docs/blob/master/zh-CN/environment/practice/index.md
在API请求的各个部分(URL、参数、头部、体、授权)中,可以使用尖双括号(例如 `<>`)来引用环境变量。Reqable会在发送请求时自动替换这些引用为实际的变量数值。
```text
<>
```
--------------------------------
### Environment Variables Introduction
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/changelogs/windows/index.md
Introduces environment variables as a new feature, allowing for dynamic configuration management. This enables users to define and use variables across different API requests and settings.
```text
Environment Variables: {{MY_VARIABLE}}
```
--------------------------------
### 检查系统代理配置
Source: https://github.com/reqable/reqable-docs/blob/master/zh-CN/faq/windows.md
指导用户如何手动检查Windows系统网络代理设置,以确保Reqable能够正常捕获流量。这包括检查代理开关、地址和端口号。
```text
Windows菜单 -> 设置 -> 网络和Internet -> 代理 -> 手动设置代理
```
--------------------------------
### Quick Repeat Request (Shortcut)
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/capture/31_repeat.mdx
Replays selected requests once each using the Control + Enter shortcut. No specific dependencies are mentioned beyond the Reqable application itself.
```text
Control + Enter
```
--------------------------------
### Modify JSON Response Data
Source: https://github.com/reqable/reqable-docs/blob/master/zh-CN/capture/24_addons.md
Example script to modify JSON data within a response.
```APIDOC
## Modify JSON Response Data
### Description
This example demonstrates how to modify JSON data within an HTTP response.
### Request
Assumed response data format:
```json
{
"code": 10000,
"message": "ok",
"content": {
"version": "1.0.0",
"platform": "windows"
}
}
```
### Goal
Change the `version` field to `2.0.0`.
### Script
```python
from reqable import *
def onRequest(context, request):
# Done
return request
def onResponse(context, response):
# Convert response body to JSON object
response.body.jsonify()
# Modify the version value in the JSON object
response.body['content']['version'] = '2.0.0'
# Done
return response
```
```
--------------------------------
### Access App Information
Source: https://github.com/reqable/reqable-docs/blob/master/zh-CN/capture/24_addons.md
Shows how to access and print information about the current application context, including its name, ID, and the path to its executable file.
```python
def onRequest(context, response):
# 打印应用信息
print(context.app.name)
print(context.app.id)
print(context.app.path)
# Done
return request
```
--------------------------------
### Secondary Proxy Configuration Help Button
Source: https://github.com/reqable/reqable-docs/blob/master/zh-CN/changelogs/macos/index.md
Adds a 'Help' button to the secondary proxy configuration page, providing users with quick access to assistance and guidance.
```text
A 'Help' button has been added to the secondary proxy configuration page.
```
--------------------------------
### New: Interceptor Configuration
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/changelogs/macos/index.md
Allows configuration of interceptors, including rewriting, in auto-highlighting.
```markdown
- 🚀 [NEW] You can configure interceptors such as rewriting in auto-highlighting.
```
--------------------------------
### API Testing Scripting in Reqable
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/changelogs/linux/index.md
Introduces scripting for API testing, including script templates and the ability to fork templates from public repositories. Also notes console support for API testing responses.
```plaintext
# Concepts related to API testing scripting.
# Examples might involve:
# - Defining test cases with scripts
# - Using pre-defined script templates
# - Executing scripts against API endpoints
# - Analyzing responses within a console
```
--------------------------------
### 导入Shortcut组件
Source: https://github.com/reqable/reqable-docs/blob/master/zh-CN/capture/01_list.mdx
导入Reqable文档中用于展示快捷键的Shortcut React组件。此组件用于包装快捷键的文本,以便在UI中以特定样式显示。
```javascript
import Shortcut from '@site/src/components/Shortcut';
```
--------------------------------
### Reqable Rewrite Overview
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/capture/26_rewrite.mdx
Provides an overview of Reqable's rewrite feature, its supported modes, and how to enable/disable it.
```APIDOC
## Reqable Rewrite Overview
### Description
Reqable's rewrite feature automatically modifies requests or responses through preset rules. It supports five modes: Redirection, Replace Request, Replace Response, Modify Request, and Modify Response.
Rewrite can be enabled or disabled in four ways:
- Click directly on the rewrite icon.
- Right-click on the rewrite icon -> Enable/Disable.
- Tray -> Rewrite -> Enable/Disable.
- Shortcut key: `Shift + Control + K`
When rewrite is enabled, the rewrite icon on the `QuickBar` turns green and active.
```
--------------------------------
### Python脚本代理终端示例
Source: https://github.com/reqable/reqable-docs/blob/master/zh-CN/faq/windows.md
展示如何使用Reqable的代理终端功能来捕获Python脚本产生的流量。适用于脚本语言,帮助其流量通过Reqable代理。
```text
代理终端
```
--------------------------------
### Fix HexViewer gets focus by default
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/changelogs/ios/index.md
Resolves a bug where the HexViewer component incorrectly gained focus by default. This ensures that focus is managed appropriately within the UI.
```text
🐞 [FIX] The bug that `HexViewer` will get focus by default.
```
--------------------------------
### Modify JSON Response Version
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/capture/24_addons.md
An example of modifying JSON response data. It shows how to jsonify the response body and update a specific value within the JSON structure.
```python
from reqable import *
def onRequest(context, request):
# Done
return request
def onResponse(context, response):
# Jsonify the response body
response.body.jsonify()
# Modify the version value in the dictionary
response.body['content']['version'] = '2.0.0'
# Done
return response
```
--------------------------------
### Supports opening browser to download CA certificate
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/changelogs/ios/index.md
Enables users to open their browser to download the CA certificate description file, facilitating trust establishment for secure connections.
```text
🚀 [NEW] Supports opening the browser to download the CA certificate description file.
```
--------------------------------
### Raw Packet Syntax Highlighting
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/changelogs/windows/index.md
Improves readability of raw packets by adding syntax highlighting for JSON and XML formats.
```text
Raw packet syntax supports JSON and XML highlighting.
```
--------------------------------
### Create Rewrite Rule
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/capture/26_rewrite.mdx
Details on how to create a new rewrite rule, including methods and supported URL matching.
```APIDOC
## Create Rewrite Rule
### Description
There are six ways to create a rewrite rule: Right-click on the rewrite icon -> Add Rewrite, Tray -> Rewrite -> Add Rewrite, Rewrite List -> Click the `+` icon, Rewrite List -> Right-Click Menu -> New, Traffic list -> Select an item -> Right-click menu -> Rewrite, or via shortcut key `Shift + Alt + G`.
When creating a rule, you need to enter a rule name and a matching URL. The URL supports wildcard `*` and `?` matching. Finally, set a rewriting behavior.
```
--------------------------------
### Application/Octet-Stream Text Display
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/changelogs/windows/index.md
Optimizes the display of `application/octet-stream` content by showing text first if it's detected as text. This improves the preview of binary data that might contain readable text.
```http
Content-Type: application/octet-stream
[Binary Data or Text Content]
```
--------------------------------
### System Proxy Status API Method
Source: https://github.com/reqable/reqable-docs/blob/master/zh-CN/changelogs/macos/index.md
Changes the method for obtaining system proxy status from shell commands to API calls. This provides a more reliable and efficient way to get this information.
```text
System proxy status is now obtained via API calls instead of shell commands.
```
--------------------------------
### Context menu for traffic overview URL
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/changelogs/ios/index.md
Implements a context menu for URLs displayed in the traffic overview. This allows for quick actions such as copying the URL or opening it in a browser.
```text
🚀 [NEW] Context menu for traffic overview URL.
```
--------------------------------
### Modify JSON Response Version
Source: https://github.com/reqable/reqable-docs/blob/master/zh-CN/capture/24_addons.md
An example of intercepting an HTTP response, converting its body to JSON, modifying a specific field ('version'), and returning the modified response. This requires the response body to be JSON.
```python
from reqable import *
def onRequest(context, request):
# Done
return request
def onResponse(context, response):
# 将响应体字典化
response.body.jsonify()
# 修改字典中的version值
response.body['content']['version'] = '2.0.0'
# Done
return response
```
--------------------------------
### New User Page Effects Improvement
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/changelogs/windows/index.md
Improves the page effects for new users when opening the application for the first time. This enhances the onboarding experience for first-time users.
```text
Onboarding Tutorial Enhancement
```
--------------------------------
### Code Editor Features in Reqable
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/changelogs/linux/index.md
Highlights code auto-completion support in the code editor and fixes for text syntax highlighting and URL formatting.
```plaintext
# Functionality related to code editor enhancements.
# Examples could include:
# - Syntax highlighting for various languages
# - Autocompletion suggestions based on context
# - Formatting for URLs, ensuring trailing slashes are handled
```
--------------------------------
### Python Script Lifecycle Example
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/capture/23_script.mdx
Demonstrates how to share data between onRequest and onResponse functions using the context.shared variable in Python scripts. The onRequest function sets a shared variable, and the onResponse function accesses it.
```python
def onRequest(context, request):
context.shared = 'foobar'
return request
def onResponse(context, response):
print(context.shared) # print foobar
return response
```
--------------------------------
### Highlighting
Source: https://github.com/reqable/reqable-docs/blob/master/zh-CN/capture/24_addons.md
Defines enumeration values for highlighting network requests.
```APIDOC
## Highlighting
### Description
Set the highlighting style for network requests.
### Enum Values
- **none**: No highlighting.
- **red**: Red highlighting.
- **yellow**: Yellow highlighting.
- **green**: Green highlighting.
- **blue**: Blue highlighting.
- **teal**: Teal highlighting.
- **strikethrough**: Strikethrough highlighting.
### Usage Example
```python
def onRequest(context, response):
# Set request to red highlight
context.highlight = Highlight.red
# Done
return request
```
```
--------------------------------
### Create Gateway Rule Shortcut
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/capture/21_gateway.mdx
This snippet details the keyboard shortcut for creating a new gateway rule within Reqable. It specifies the key combination used to initiate the rule creation process.
```Markdown
Shortcut key Shift + Alt + G
```
--------------------------------
### Python Scripting Enhancements
Source: https://github.com/reqable/reqable-docs/blob/master/zh-CN/changelogs/linux/index.md
Python scripts can now directly enable 'Visual Studio Code' for editing, streamlining the development workflow for users who prefer VS Code.
```python
# Example: Python script to open VS Code for editing
# (This is a conceptual representation of the feature)
import subprocess
def open_script_in_vscode(script_path):
try:
subprocess.run(['code', script_path], check=True)
print(f'Opened {script_path} in Visual Studio Code.')
except FileNotFoundError:
print('Error: Visual Studio Code (code command) not found in PATH.')
except Exception as e:
print(f'An error occurred: {e}')
# Assuming 'my_script.py' is the script to be edited
# open_script_in_vscode('my_script.py')
```
--------------------------------
### Rewrite Behaviors and Priority
Source: https://github.com/reqable/reqable-docs/blob/master/en-US/capture/26_rewrite.mdx
Explains the five supported rewriting behaviors and their execution priority.
```APIDOC
## Rewrite Behaviors and Priority
### Description
Reqable supports five rewriting behaviors: Redirection, Replace Request, Replace Response, Modify Request, and Modify Response. The priority order is: redirection > replacement > modification.
- A request can trigger at most one redirection rule.
- A request can trigger multiple replacement rules, executed in the order of the rule list.
- A request can trigger multiple modification rules, executed in the order of the rule list.
- Replacement and modification rules match the new URL after redirection, not the original request URL.
```
--------------------------------
### Context API
Source: https://github.com/reqable/reqable-docs/blob/master/zh-CN/capture/24_addons.md
Provides access to information about the current network request context and allows for global environment variable management and debugging highlights.
```APIDOC
## Context API
### Description
Provides access to information about the current network request context, including URL, scheme, host, port, connection IDs, timestamps, and application information. It also allows for managing global and custom environment variables and setting highlight properties for debugging.
### Read-only Properties
- `*url*` (str) - The request URL.
- `*scheme*` (str) - The request scheme (http or https).
- `*host*` (str) - The request host/domain.
- `*port*` (int) - The request port number.
- `*cid*` (int) - The TCP connection ID.
- `*ctime*` (int) - The TCP connection start timestamp in milliseconds.
- `*sid*` (int) - The HTTP session ID.
- `*stime*` (int) - The HTTP session start timestamp in milliseconds.
- `*uid*` (str) - A unique identifier for the HTTP session, composed of `ctime`, `cid`, and `sid`.
- `*app*` ([App](#api-app)) - Application (process) information, or None if not available.
### Writable Properties
- `**env**` (dict) - A collection of global environment variables and currently active custom environment variables. Can be used to read and write variables.
- `**shared**` (-) - A special variable for sharing data between `onRequest` and `onResponse`. Supports automatically serializable types like str, int, list, and dict.
### Special Properties
- `highlight` ([Highlight](#api-highlight)) - Sets the highlight attribute for the debug list. Added in v2.28.0.
### Example Usage
```python
def onRequest(context, request):
# Accessing read-only properties
print(context.url)
print(context.scheme)
print(context.host)
print(context.port)
print(context.cid)
print(context.ctime)
print(context.sid)
print(context.stime)
print(context.uid)
# Accessing and modifying environment variables
print(context.env['foo'])
print(context.env['$timestamp'])
context.env['foo'] = 'bar' # Writes to the active custom environment or global environment
# Setting highlight
context.highlight = Highlight.red
# Setting shared data
context.shared = 'Hello'
return request
def onResponse(context, response):
# Accessing shared data
print(context.shared)
return response
```
```