GithubHelp home page GithubHelp logo

httpsoft / http-message Goto Github PK

View Code? Open in Web Editor NEW
74.0 4.0 4.0 150 KB

Strict and fast implementation of PSR-7 and PSR-17

Home Page: https://httpsoft.org/docs/message

License: MIT License

PHP 100.00%
php http psr-7 psr-17 http-message request-response

http-message's Introduction

HTTP Message

License Latest Stable Version Total Downloads GitHub Build Status GitHub Static Analysis Status Scrutinizer Code Coverage Scrutinizer Code Quality

This package is a lightweight, fast, high-performance and strict implementation of the PSR-7 HTTP Message and PSR-17 HTTP Factories.

The package does not contain any additional functionality other than that defined in the PSR interfaces.

Documentation

Installation

This package requires PHP version 7.4 or later.

composer require httpsoft/http-message

Benchmark

Runs: 30,000 Guzzle HttpSoft Laminas Nyholm Slim
Runs per second 15868 19544 12257 19022 12117
Average time per run 0.0630 ms 0.0512 ms 0.0816 ms 0.0526 ms 0.0825 ms
Total time 1.8905 s 1.5349 s 2.4474 s 1.5771 s 2.4757 s

See benchmark at https://github.com/devanych/psr-http-benchmark.

Usage

For a description of how to use the package components, see the PSR-7 and PSR-17 specifications and package documentation.

For the convenience of creating requests to the server from PHP superglobals, you can use the httpsoft/http-server-request package.

composer require httpsoft/http-server-request

You can use the httpsoft/http-runner package to run requests to the server and emit responses, as well as build the PSR-15 middleware pipelines.

composer require httpsoft/http-runner

http-message's People

Contributors

arogachev avatar devanych avatar enjoyzz avatar roxblnfk avatar samdark avatar vjik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

http-message's Issues

Running HttpSoft implementation agains set of tests

I compiled this list of tests for http-message spec: https://github.com/hamlet-framework/http-message-spec

The tests are kept as traits, so it shouldn't be a problem to reuse in your project if the need arises. In any case, there are few issues, feel free to check out the latest master and run all tests/HttpSoft* for more details. One notable issue is how you handle Host header.

Also, my benchmark results look quite different from yours:

Comprehensive test
+----------------------+--------------------+-------------------+--------------+
| Function description | Execution time (s) | Memory usage (mb) | Times faster |
+----------------------+--------------------+-------------------+--------------+
| ring-central         | 4.0299             | 0.0970            | 14%          |
| nyholm               | 4.5991             | 0.1470            | 12%          |
| guzzle               | 5.1903             | 0.3000            | 13%          |
| hamlet-framework     | 5.8748             | 0.3160            | 31%          |
| zend-diactoros       | 7.6987             | 0.1780            | 3%           |
| http-soft            | 7.9331             | 0.1530            | 25%          |
| wind-walker          | 9.9951             | 0.3440            | 0            |
+----------------------+--------------------+-------------------+--------------+
Fetching test
+----------------------+--------------------+-------------------+--------------+
| Function description | Execution time (s) | Memory usage (mb) | Times faster |
+----------------------+--------------------+-------------------+--------------+
| hamlet-framework     | 1.7709             | 0.0000            | 17%          |
| ring-central         | 2.0741             | 0.0000            | 3%           |
| nyholm               | 2.1567             | 0.0000            | 4%           |
| guzzle               | 2.2612             | 0.0000            | 44%          |
| zend-diactoros       | 3.2708             | 0.0010            | 12%          |
| wind-walker          | 3.6730             | 0.0010            | 6%           |
| http-soft            | 3.9247             | 0.0000            | 0            |
+----------------------+--------------------+-------------------+--------------+

`ServerRequestFactory` created request with incorrect parsed body

Parsed body always null, but by PSR-7 in certain cases, it must contain certain values:

If the request Content-Type is either application/x-www-form-urlencoded
or multipart/form-data, and the request method is POST, this method MUST
return the contents of $_POST.

Otherwise, this method may return any results of deserializing
the request body content; as parsing returns structured content, the
potential types MUST be arrays or objects only. A null value indicates
the absence of body content.

createStreamFromFile throw incorrect exception in PHP 8

Description

$streamFactory->createStreamFromFile('', 'r');

throw ValueError: Path cannot be empty, but should RuntimeException by PSR-17.

Already been this bug in previous version PHP: #5

Additional info

Q A
Package version 1.0.6
PHP version 8.0
Operating system Win10

Use of mutation testing in http-message - Help needed

Hello there!

My name is Ana. I noted that you use the mutation testing tool infection in the project.
I am a postdoctoral researcher at the University of Seville (Spain), and my colleagues and I are studying how mutation testing tools are used in practice. With this aim in mind, we have analysed over 3,500 public GitHub repositories using mutation testing tools, including yours! This work has recently been published in a journal paper available at https://link.springer.com/content/pdf/10.1007/s10664-022-10177-8.pdf.

To complete this study, we are asking for your help to understand better how mutation testing is used in practice, please! We would be extremely grateful if you could contribute to this study by answering a brief survey of 21 simple questions (no more than 6 minutes). This is the link to the questionnaire https://forms.gle/FvXNrimWAsJYC1zB9.

Drop me an e-mail if you have any questions or comments ([email protected]). Thank you very much in advance!!

getStream->getContents is empty

Description
See comment a01ec15#r78665198
Maybe I'm wrong, but everything works in guzzle and Nyholm, but not here (((

Possible solution
"r+" mode is needed , otherwise content is empty

Additional info

Q A
Package version 1.0.9
PHP version 8.0
Operating system Ubuntu

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.