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

Proxy/Intercept pattern is throwing a keep alive header error with net461 #70

Closed
Curtis004 opened this issue Dec 7, 2017 · 5 comments
Closed
Assignees

Comments

@Curtis004
Copy link

Curtis004 commented Dec 7, 2017

Hello!

Trying to get proxying working with the following example:

FluentMockServer server = FluentMockServer.StartWithAdminInterface(port: 8088); server.Given(Request.Create().WithPath("*")).AtPriority(10).RespondWith(Response.Create().WithProxy("http://restcountries.eu/"));

But its throwing me this:
{ "ClassName": "System.ArgumentException", "Message": "The 'Keep-Alive' header must be modified using the appropriate property or method.", "Data": null, "InnerException": null, "HelpURL": null, "StackTraceString": " at System.Net.WebHeaderCollection.ThrowOnRestrictedHeader(String headerName)\r\n at System.Net.WebHeaderCollection.Set(String name, String value)\r\n at Microsoft.Owin.Host.HttpListener.RequestProcessing.ResponseHeadersDictionary.Set(String header, String value)\r\n at Microsoft.Owin.Host.HttpListener.RequestProcessing.HeadersDictionaryBase.Set(String key, String[] value)\r\n at WireMock.Owin.OwinResponseMapper.<>c__DisplayClass1_0.<MapAsync>b__1(KeyValuePair'2 pair)\r\n at System.Collections.Generic.List'1.ForEach(Action'1 action)\r\n at WireMock.Owin.OwinResponseMapper.<MapAsync>d__1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at WireMock.Owin.WireMockMiddleware.<Invoke>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at WireMock.Owin.GlobalExceptionMiddleware.<Invoke>d__2.MoveNext()", "RemoteStackTraceString": null, "RemoteStackIndex": 0, "ExceptionMethod": "8\nThrowOnRestrictedHeader\nSystem, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\nSystem.Net.WebHeaderCollection\nVoid ThrowOnRestrictedHeader(System.String)", "HResult": -2147024809, "Source": "System", "WatsonBuckets": null, "ParamName": "name" }

I can see in the request log however that the request is proxied properly:

[ { "Guid": "8c509c3a-db4e-407f-baf1-7e8eecb5e408", "Request": { "ClientIP": "::1", "DateTime": "2017-12-07T19:30:36.7224812+00:00", "Path": "/rest/v2/all", "AbsoluteUrl": "http://localhost:8088/rest/v2/all", "Method": "get", "Headers": { "Postman-Token": [ "a936e818-4c09-49f5-a3b1-efebdd6bedcc" ], "Cache-Control": [ "no-cache" ], "Connection": [ "keep-alive" ], "Accept": [ "*/*" ], "Accept-Encoding": [ "gzip, deflate" ], "Host": [ "localhost:8088" ], "User-Agent": [ "PostmanRuntime/7.1.1" ] } }, "Response": { "StatusCode": 200, "Headers": { "Keep-Alive": [ "timeout=5, max=100" ], "Access-Control-Allow-Methods": [ "GET" ], "Access-Control-Allow-Headers": [ "Accept, X-Requested-With" ], "Content-Type": [ "application/json; charset=utf-8" ], "Access-Control-Allow-Origin": [ "*" ], "Date": [ "Thu, 07 Dec 2017 19:30:37 GMT" ], "Connection": [ "Keep-Alive" ], "Transfer-Encoding": [ "chunked" ], "Server": [ "Apache/2.4.25", "(Debian)" ], "Cache-Control": [ "public, max-age=86400" ] }, "Body": "[{\"name\":\"Afghanistan\",\"topLevelDomain\":[\".af\"],\"alpha2Code\":\"AF\",\"alpha3Code\":\"AFG\",\"callingCodes\":[\"93\"],\"capital\":\"Kabul\",\"altSpellings\":[\"AF\",\"Afġānistān\"],\"region\":\"Asia\",\"subregion\":\"Southern Asia\",\"population\":27657145,\"latlng\":[33.0,65.0],\"demonym\":\"Afghan\",\"area\":652230.0,\"gini\":27.8,\"timezones\":[\"UTC+04:30\"],\"borders\":[\"IRN\",\"PAK\",\"TKM\",\"UZB\",\"TJK\",\"CHN\"],\"nativeName\":\"افغانستان\",\"numericCode\":\"004\",\"currencies\":[{\"code\":\"AFN\",\"name\":\"Afghan afghani\",\"symbol\":\"؋\"}],\"languages\":[{\"iso639_1\":\"ps\",\"iso639_2\":\"pus\",\"name\":\"Pashto\",\"nativeName\":\"پښتو\"},{\"iso639_1\":\"uz\",\"iso639_2\":\"uzb\",\"name\":\"Uzbek\",\"nativeName\":\"Oʻzbek\"},{\"iso639_1\":\"tk\",\"iso639_2\":\"tuk\",\"name\":\"Turkmen\",\"nativeName\":\"Türkmen\"}],\"translations\":{\"de\":\"Afghanistan\",\"es\":\"Afganistán\",\"fr\":\"Afghanistan\",\"ja\":\"アフガニスタン\",\"it\":\"Afghanistan\",\"br\":\"Afeganistão\",\"pt\":\"Afeganistão\",\"nl\":\"Afghanistan\",\"hr\":\"Afganistan\",\"fa\":\"افغانستان\"},\"flag\":\"https://restcountries.eu/data/afg.svg\",\"regionalBlocs\":[{\"acronym\":\"SAARC\",\"name\":\"South Asian Association for Regional Cooperation\",\"otherAcronyms\":[],\"otherNames\":[]}],\"cioc\":\"AFG\"},{\"name\":\"Åland Islands\",\"topLevelDomain\":[\".ax\"],\"alpha2Code\":\"AX\",\"alpha3Code\":\"ALA\",\"callingCodes\":[\"358\"],\"capital\":\"Mariehamn\",\"altSpellings\":[\"AX\",\"Aaland\",\"Aland\",\"Ahvenanmaa\"],\"region\":\"Europe\",\"subregion\":\"Northern Europe\",\"population\":28875,\"latlng\":[60.116667,19.9],\"demonym\":\"Ålandish\",\"area\":1580.0,\"gini\":null,\"timezones\":[\"UTC+02:00\"],\"borders\":[],\"nativeName\":\"Åland\",\"numericCode\":\"248\",\"currencies\":[{\"code\":\"EUR\",\"name\":\"Euro\",\"symbol\":\"€\"}],\"languages\":[{\"iso639_1\":\"sv\",\"iso639_2\":\"swe\",\"name\":\"Swedish\",\"nativeName\":\"svenska\"}],\"translations\":{\"de\":\"Åland\",\"es\":\"Alandia\",\"fr\":\"Åland\",\"ja\":\"オーランド諸島\",\"it\":\"Isole Aland\",\"br\":\"Ilhas de Aland\",\"pt\":\"Ilhas de Aland\",\"nl\":\"Ålandeilanden\",\"hr\":\"Ålandski otoci\",\"fa\":\"جزایر الند\"},\"flag\":\"https://restcountries.eu/data/ala.svg\",\"regionalBlocs\":[{\"acronym\":\"EU\",\"name\":\"European Union\",\"otherAcronyms\":[],\"otherNames\":[]}],\"cioc\":\"\"},{\"name\":\"Albania\",\"topLevelDomain\": ... etc.

Any ideas what I'm doing wrong?

@StefH StefH self-assigned this Dec 7, 2017
@StefH
Copy link
Collaborator

StefH commented Dec 7, 2017

I can imagine that Keep-Alive is a reserved header.

Are you using netcore or .net 4.x ?

@Curtis004
Copy link
Author

Curtis004 commented Dec 7, 2017

net4.6.1, I'm not explicitly setting any headers.

@StefH
Copy link
Collaborator

StefH commented Dec 7, 2017

New NuGet is uploaded, please retest.

@Curtis004
Copy link
Author

Great! Amazing turn around time. Will re-test once back in office and let you know. Thanks.

@Curtis004
Copy link
Author

This is working now, thanks for the quick assist!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants