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

Ignore OPTIONS request when using proxyandrecord #899

Closed
bhargavjulaganti opened this issue Mar 7, 2023 · 10 comments
Closed

Ignore OPTIONS request when using proxyandrecord #899

bhargavjulaganti opened this issue Mar 7, 2023 · 10 comments
Assignees
Labels

Comments

@bhargavjulaganti
Copy link

I am using wire mock as a standalone server, to record my web requests. Currently it is recording OPTIONS request as well when saving the mapping to the file .

Is there an extension I could use, so it does not save OPTIONS request, like how we are excluding specific headers not to save in mappings file

var url = "http://localhost:9095";

Console.WriteLine($"WireMock Recording on {url}");

var settings = new WireMockServerSettings
{
    Urls = new[] { url },
    StartAdminInterface = true,
    ProxyAndRecordSettings = new ProxyAndRecordSettings
    {
        Url = "random url",
        SaveMapping = true,
        SaveMappingToFile = true,
        SaveMappingForStatusCodePattern = "2xx,4xx",
        ExcludedHeaders = new[]
        {
            "Postman-Token",
            "Host",
            "Authorization",
            "User-Agent",
            "Cache-Control"
        }
    }
};

var server = WireMockServer.Start(settings);
@StefH
Copy link
Collaborator

StefH commented Mar 8, 2023

@bhargavjulaganti
This can be added.

I'll take a look.

@StefH StefH self-assigned this Mar 8, 2023
@StefH StefH added feature and removed question labels Mar 8, 2023
@StefH
Copy link
Collaborator

StefH commented Mar 8, 2023

Can you try preview version (1.5.17-ci-17145) ?

https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions

@bhargavjulaganti
Copy link
Author

I updated the version to 1.5.17-ci-17145 and tried it. I am still seeing OPTIONS file is getting created

image

image

@StefH
Copy link
Collaborator

StefH commented Mar 8, 2023

Please try 17147

@bhargavjulaganti
Copy link
Author

still seeing the same issue. When I look at your change , I see you are looking for request matchers.

I do not have any request matchers in my code. I am just running wiremock as a standalone application

@StefH
Copy link
Collaborator

StefH commented Mar 8, 2023

You are correct.

Actually a new setting like DoNotSaveMappingForHttpMethods should be added. Just like SaveMappingForStatusCodePattern.

@StefH
Copy link
Collaborator

StefH commented Mar 8, 2023

@bhargavjulaganti
New code works like:

ProxyAndRecordSettings = new ProxyAndRecordSettings
            {
                Url = "http://www.google.com",
                SaveMapping = true,
                SaveMappingToFile = true,
                SaveMappingSettings = new ProxySaveMappingSettings
                {
                    StatusCodePattern = "2xx,4xx",
                    HttpMethods = new ProxySaveMappingSetting<string[]>(new string[] { "GET" }, MatchBehaviour.RejectOnMatch) // To make sure that we don't want this mapping
                }
            },

(new preview NuGet will be published within some minutes, just take the most recent version)

@bhargavjulaganti
Copy link
Author

That worked . Thanks for the quick update :)

image

@StefH
Copy link
Collaborator

StefH commented Mar 9, 2023

#900

@StefH
Copy link
Collaborator

StefH commented Mar 9, 2023

An official NuGet will be released in the next days.

@StefH StefH closed this as completed Mar 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants