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

Improve WebAPI compatibility #40

Open
9 of 28 tasks
g105b opened this issue Nov 11, 2020 · 4 comments
Open
9 of 28 tasks

Improve WebAPI compatibility #40

g105b opened this issue Nov 11, 2020 · 4 comments

Comments

@g105b
Copy link
Member

g105b commented Nov 11, 2020

https://developer.mozilla.org/en-US/docs/Web/API

There are a few classes in the WebAPI that have functionality shared by this implementation of PSR-7 which should be implemented.

Functions:

  • Message::arrayBuffer() - Returns a promise
  • Message::blob() - Returns a promise
  • Message::formData() - Returns a promise
  • Message::json() - Returns a promise
  • Message::text() - Returns a promise

Properties:

  • Response::ok
  • Response::headers
  • Response::redirected
  • Response::status
  • Response::statusText
  • Response::type
  • Response::uri
  • Response::useFinalUri

  • Request::cache
  • Request::context
  • Request::credentials
  • Request::destination
  • Request::headers
  • Request::integrity
  • Request::method
  • Request::mode
  • Request::redirect
  • Request::referrer
  • Request::referrerPolicy
  • Request::url

@g105b
Copy link
Member Author

g105b commented Nov 11, 2020

Before any of this can be completed, the Promise class needs to be available from https://github.com/PhpGt/Async

@g105b
Copy link
Member Author

g105b commented Dec 23, 2020

FormData class was left as a stub in the repository which is now failing PHPStan. Here's the class:

<?php
namespace Gt\Http;

class FormData {
	/** @var array */
	protected $data;

	public function __construct(array $data = []) {
		$this->data = $data;
	}

	public function append(
		string $key,
		string $value,
		string $filename = null
	):void {

	}

	public function set(
		string $name,
		string $value,
		string $filename = null
	):void {

	}

	public function delete(string $name):void {

	}

	public function entries():array {

	}

	public function get(string $name):?string {

	}

	public function getAll(string $name):array {

	}

	/** For consistency with naming of other Web APIs. */
	public function contains(string $name):bool {

	}

	public function has(string $name):bool {

	}

	public function keys():array {

	}

	public function values():array {

	}
}

@g105b
Copy link
Member Author

g105b commented Jan 2, 2021

Different Body types that need implementing:

body
Any body that you want to add to your request: this can be a Blob, BufferSource, FormData, URLSearchParams, USVString, or ReadableStream object. Note that a request using the GET or HEAD method cannot have a body.

g105b added a commit that referenced this issue Jan 6, 2021
@g105b
Copy link
Member Author

g105b commented Jan 6, 2021

This latest push has implementations of some of the classes, and properties have been made consistent.

Still to do:

  1. Complete the class implementations.
  2. Link the external async loop to the promises.

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