Skip to content

Support Request and Headers objects as parameter #141

@jason076

Description

@jason076

Hi, I am trying to create a container in a solid pod using the the fetch() method of the solid-auth-client. I create the POST request as follows:

public createContainer(url: string, name: string): void {
        const reqHeader = new Headers();
        reqHeader.append('Host', 'example.org');
        reqHeader.append('Content-Type', 'text/turtle');
        reqHeader.append(
            'Link',
            '<http://www.w3.org/ns/ldp#BasicContainer>; rel="type"'
        );
        reqHeader.append('Slug', name);
        const req = new Request(url, {
            method: 'POST',
            headers: reqHeader,
            body: '<> <http://purl.org/dc/terms/title> "Basic container" .'
        });

        this.authService.fetch(req).then(res => {
            if (!res.ok) {
                throw new SolidFailedCreatingContainer(url, name);
            }
        });
    }

The call to this.authService.fetch() is just a wrapper for window.solid.auth.fetch(). I'm using solid-auth-client v 2.3.1.

The call from above results into the following header:

POST /your-companion HTTP/1.1
Host: jason07.localhost:8443
Connection: keep-alive
Content-Length: 55
Pragma: no-cache
Cache-Control: no-cache
authorization: Bearer 
<TOKEN_OMITTED>
Origin: http://localhost:8100
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.87 Safari/537.36
Accept: */*
Sec-Fetch-Site: cross-site
Sec-Fetch-Mode: cors
Referer: http://localhost:8100/negative-thoughts
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Cookie: <COOKIE_OMITTED>

All header fields that I have added to the request are missing.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions