Comments (2)
Thank you @Sammyjo20! I didn't know about these HTTP methods either just last week. =) Very much an edge case though as they seem to be more or less specific to WebDAV.
Your solution is working great. I did try similar ideas but managed to miss handlePsrRequest
. Thank you again and have a great week!
from saloon.
Hey @mikaeljorhult
I have never heard of these HTTP methods before! 😅 The HTTP method is an enum so I think it would be difficult to extend it... That being said you may be able to hack it slightly by writing a PSR handler in your connector. For example
Your connector
You could add a method called handlePsrRequest
and change the HTTP method from a method you can add from your request class.
<?php
namespace App\Http\Integrations\Test;
use Psr\Http\Message\RequestInterface;
use Saloon\Http\Connector;
use Saloon\Http\PendingRequest;
use Saloon\Traits\Plugins\AcceptsJson;
class TestConnector extends Connector
{
use AcceptsJson;
/**
* The Base URL of the API
*/
public function resolveBaseUrl(): string
{
return 'https://tests.saloon.dev/api';
}
/**
* Default headers for every request
*/
protected function defaultHeaders(): array
{
return [];
}
/**
* Default HTTP client options
*/
protected function defaultConfig(): array
{
return [];
}
public function handlePsrRequest(RequestInterface $request, PendingRequest $pendingRequest): RequestInterface
{
return $request->withMethod($pendingRequest->getRequest()->getNativeMethod());
}
}
Your request
You would add the getNativeMethod
on your request like this
<?php
namespace App\Http\Integrations\Test\Requests;
use GuzzleHttp\RequestOptions;
use Saloon\Enums\Method;
use Saloon\Http\Request;
class UserRequest extends Request
{
/**
* The HTTP method of the request
*/
protected Method $method = Method::GET;
/**
* The endpoint for the request
*/
public function resolveEndpoint(): string
{
return '/user';
}
public function getNativeMethod(): string
{
return 'PROPFIND';
}
}
With this way, you would be overwriting the protected Method $method
property on your request, so this could be anything.
from saloon.
Related Issues (20)
- Cannot Have Request with `headers` HOT 4
- Skipping authentication when request is cached HOT 5
- Skipping AuthenticatePendingRequest when fetching a new accessToken using OAuth2 plugins HOT 3
- OAuth2 - Method not allowed (405) when getting the access Token HOT 8
- Missing methods updates for MockResponse HOT 1
- ERROR There are no commands defined in the "saloon" namespace. HOT 1
- Rate Limit Plugin: Issue with 'allow(1)->everySeconds(1)->sleep()' Exceeding One Request per Second
- Inteliphense cannot recognize the merge() method on request HOT 3
- Connector default headers overwrite request body headers
- Remove authentication on a specific request HOT 1
- Some properties are removed from the response body
- Generating Documentation Files for GPT on ChatGPT
- Tests using Fixtures with custom Authenticators record incorrect response HOT 1
- async request with multi connector
- Allow partial overriding of fixtures HOT 1
- Asserting a request is sent by closure parameter
- Connector object() throws an exception but json returns null|object?
- Feature Request: Requests have the ability to return a Colleciton HOT 1
- Connector does not support `defaultBody()`?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from saloon.