Skip to content

some suggestion #19

@zhongjq

Description

@zhongjq

src\Support\Http.php

public function json($url, $data = [], $queries = [], array $options = [], $encodeOption = JSON_UNESCAPED_UNICODE){
        is_array($data) && $data = json_encode($data, $encodeOption);

        $this->setHeaders(['Content-Type' => 'application/json']);

        return $this->request('POST', $url, array_merge([
            'query' => $queries,
            'body' => $data,
        ], $options));
 }

It is proposed to be changed as follows

public function json($url, $data = [], $queries = [], array $options = [], $encodeOption = JSON_UNESCAPED_UNICODE){
        is_array($data) && $data = json_encode($data, $encodeOption);

        $options = array_merge($options, ['header' => ['Content-Type' => 'application/json']]);

        return $this->request('POST', $url, array_merge([
            'query' => $queries,
            'body' => $data,
        ], $options));
 }

$this->setHeaders(['Content-Type' => 'application/json']); It is be a global setting, and it will dirty other requests

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