Skip to content

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

@cristianorevil

Description

@cristianorevil

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

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