Hi
Burp handles this conversion itself when you specify the HttpMode.
You can see this in the following example:
import burp.api.montoya.BurpExtension;
import burp.api.montoya.MontoyaApi;
import burp.api.montoya.http.HttpMode;
import burp.api.montoya.http.message.requests.HttpRequest;
@SuppressWarnings("unused")
public class Extension implements BurpExtension
{
@Override
public void initialize(MontoyaApi montoyaApi)
{
HttpRequest request = HttpRequest.httpRequestFromUrl("https://portswigger-labs.net");
montoyaApi.http().sendRequest(request, HttpMode.HTTP_1);
montoyaApi.http().sendRequest(request, HttpMode.HTTP_2);
}
}
If you build and load this extension and then check your Logger tab, you should see two requests, one sent with HTTP/1 and one sent with HTTP/2. To verify which request is sent with which protocol, make sure to expand the "Request attributes" section in Inspector.
We've not made any edits to the request itself, it's the same one sent each time with a different mode.
The only time you should need to build an "http2Request" specifically is if you wish to do something complicated like "kettling" a request (e.g. adding a new line in a header name or value whilst still being part of the same header).
Please let me know how you get on.