Skip to content

Check response status code before parsing and print request and response for debug purposes #450

@tux-mind

Description

@tux-mind

What happened?

Good evening, thank you again for this awesome project and to keep it alive and well!

I'm trying to download an app with the following command:

$ ipatool --keychain-passphrase secret --verbose --non-interactive --format json download --purchase -i 409157308 -o /tmp/
{"level":"debug","error":"failed to send http request: failed to unmarshal xml: plist: error parsing text property list: unexpected hex digit `!' at line 0 character 2","time":"2026-02-18T20:55:09Z"}
{"level":"error","error":"failed to send http request: failed to unmarshal xml: plist: error parsing text property list: unexpected hex digit `!' at line 0 character 2","success":false,"time":"2026-02-18T20:55:09Z"}

It would be great to be able to enable trace logs for snet and received HTTP messages.
However, I used gdb to get a dump of the response:

<!DOCTYPE html>
<html lang="en">
<head>
    <style>
        body {
            font-family: "Helvetica Neue", "HelveticaNeue", Helvetica, Arial, sans-serif;
            font-size: 15px;
            font-weight: 200;
            line-height: 20px;
            color: #4c4c4c;
            text-align: center;
        }

        .section {
            margin-top: 50px;
        }
    </style>
</head>
<body>
<div class="section">
    <h1>&#63743;</h1>

    <h3>Bad Gateway</h3>
    <p>Correlation Key: REDACTED</p>
</div>
</body>
</html>

The response StatusCode is 502 and the inputs for the request generating function shall generate a request similar to the following:

curl -X POST "https://p72-buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/volumeStoreDownloadProduct?guid=REDACTED" \
     -H "Content-Type: application/x-apple-plist" \
     -H "X-Dsid: REDACTED" \
     -H "X-Apple-Store-Front: 143441-1,34" \
     -H "X-Token: REDACTED" \
     -d '<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>salableAdamId</key>
    <string>409157308</string>
    <key>appExtVrsId</key>
    <string>0</string>
    <key>extVrsId</key>
    <string>0</string>
</dict>
</plist>'

Strangely this is happening most of the times I try to download any app. Every now and then it goes through and I get a valid response that allow me to complete the download.

It would be nice to understand why this happens, perhaps a bug in the new Anisette authentication / redirect?
If there is a way to enable HTTP trace it would be easier to spot the differences between accepted and rejected requests.

Thank you for all the hard work!

Version

19ffd1b

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions