tobi
July 18, 2019, 2:10pm
1
Given the following RequestDTO:
public class HeadSample : IReturnVoid
{
public string Id { get; set; }
}
http HEAD http://localhost/api/json/reply/HeadSample?id=196-A -> Id Property is not pouplated
http HEAD http://localhost/api/head-sample?id=196-A -> Id Property is populated
I expect both scenarios to be the same.
this was already mentioned once on stackoverflow: https://stackoverflow.com/questions/23198379/servicestack-head-request-with-query-parameter-not-working
seems to be a bug in my eyes.
tobi
mythz
July 18, 2019, 3:02pm
2
Are you sure it’s not the other way around, this request:
http://localhost/api/head-sample?id=196-A
Does not match this route:
[Route("/head-sample/{Id}", "HEAD")]
public class HeadSample : IReturnVoid
{
public string Id { get; set; }
}
Which requires the Id
in the path-info as specified in the route:
http://localhost/api/head-sample/196-A
tobi
July 22, 2019, 2:18pm
3
oh i wrote it in the wrong way, 2nd chance:
Id property not puplated:
http HEAD http://localhost/api/json/reply/HeadSample?id=196-A
Id property is populated:
http HEAD http://localhost/api/head-sample/196-A
The problem is that the typescript client is using the default routes /json/reply/{DtoName}
which then ends in an empty request dto on server side.
My expectation:
while using the default route, SS should find the dto/service impl and map the values from body/path/query-string automatically.
This already works for GET
/POST
with different behaviors depending on the HTTP verb:
GET
parameters are passed by query params, POST
is using the HTTP body.
My expectation would be that HEAD
behaves similar as GET
.
mythz
July 22, 2019, 5:39pm
4
Should be resolved from this commit .
This change is available from the latest v5.5.1 that’s now available on MyGet .
tobi
July 23, 2019, 9:21am
6
any reasons why HEAD
is missing in default methods in CorsFeature.cs
?
namespace ServiceStack
{
/// <summary>
/// Plugin adds support for Cross-origin resource sharing (CORS, see http://www.w3.org/TR/access-control/).
/// CORS allows to access resources from different domain which usually forbidden by origin policy.
/// </summary>
public class CorsFeature : IPlugin
{
public const string DefaultOrigin = "*";
public const string DefaultMethods = "GET, POST, PUT, DELETE, PATCH, OPTIONS, HEAD";
public const string DefaultHeaders = "Content-Type";
private readonly string allowedOrigins;
private readonly string allowedMethods;
private readonly string allowedHeaders;
private readonly string exposeHeaders;
private readonly int? maxAge;
private readonly bool allowCredentials;
mythz
July 23, 2019, 3:06pm
7
Don’t recall why it wasn’t included, but it’s just a default which can be changed. I’ve also added it to DefaultMethods in this commit .
This change is available from the latest v5.5.1 on MyGet .
tobi
July 24, 2019, 6:43am
8
yeah we did override it already.
just thought that it make sense to add, otherwise it feels like a little trap
thank you!
1 Like