Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for user session in rabbithole (introduced in cheshire cat 1.4) #5

Open
cristianorevil opened this issue Dec 18, 2023 · 0 comments

Comments

@cristianorevil
Copy link

cristianorevil commented Dec 18, 2023

Cheshire cat 1.4 introduce sessions for users, also when a file is sent to rabbithole, to enable this on your code simply edit the CCatClient.php file on line 93 in this way:

public function rabbitHole(string $filePath, ?string $fileName, ?int $chunkSize, ?int $chunkOverlap, string $user_id = 'user'): PromiseInterface
{
$promise = $this->httpClient->getHttpClient()->postAsync('rabbithole/', [
'multipart' => [
[
'name' => 'file',
'contents' => Utils::tryFopen($filePath, 'r'),
'filename' => $fileName ?? null
],
'headers' => ['user_id' => $user_id]
]
]);

    return $promise;
}

/**
 * @param string $webUrl
 * @param int|null $chunkSize
 * @param int|null $chunkOverlap
 * @return PromiseInterface
 */
public function rabbitHoleWeb(string $webUrl, ?int $chunkSize, ?int $chunkOverlap, string $user_id = 'user'): PromiseInterface
{
    $promise = $this->httpClient->getHttpClient()->postAsync('rabbithole/web/', [
        'json' => [
            'url' => $webUrl
        ],
        'headers' => ['user_id' => $user_id]
    ]);

    return $promise;
}

I suggest also to set the rabbithole/web enpoint with abbithole/web/ because if the cat is behind a nginx https reverse proxy there is a 301 response code if non end slash is present

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant