8000 Feature Request - Create a setter method to sets the encoding when parsing the response as a Document · Issue #997 · jhy/jsoup · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Feature Request - Create a setter method to sets the encoding when parsing the response as a Document #997
Open
@julianomqs

Description

@julianomqs

Hi,

I'm using your library in some projects here, it's great.

It would be great to have a setter method to set the encoding when parsing a response as a document.

For example, if I need to execute a post request and parse the response as a Document with the ISO-8859-1 encoding, I have to do this:

private Document executeRequest(String value2) throws IOException {
    return Jsoup.connect(DEFAULT_URL)
        .timeout(DEFAULT_TIMEOUT)
        .data("param1", "value1")
        .data("param2", value2)
        .userAgent(DEFAULT_USER_AGENT)
        .method(Method.POST)
        .execute()
        .charset(CHARSET_ISO_8859_1)
        .parse();
}

It would be great something like this:

private Document executeRequest(String value2) throws IOException {
    return Jsoup.connect(DEFAULT_URL)
        .timeout(DEFAULT_TIMEOUT)
        .data("param1", "value1")
        .data("param2", value2)
        .userAgent(DEFAULT_USER_AGENT)
        .responseEncoding("ISO-8859-1") // <-- This is the setter method I'm suggesting, something like that
        .post();
}

The postDataCharset method sets the charset when sending a POST request, but not for parsing the response as a document.

Of course the method name is your choice.

What do you think?

P.S: @krystiangorecki This is the issue with the correct description.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0