customizing HTTP Request Headers - http

How we can control over the number of header going with the HTTP request? e.g.; If I don't want to send the "Cache-Control" header,how to control it?
I am using HttpClient for sending a JSON formatted request.
Using 4.5.1 version of org.apache.httpcomponents and 3.1 version of commons-httpclient in maven dependencies.

Related

Migration a jmeter project from v3 to v5 : issue with soap request

i have a working project with jmeter 3.1 using soap request sampler :
Project Jmeter with version 3.1
Http header manager congig
i tried to figure out the same project with jmeter version 5 using http request like this :
Project jmeter version5
but i receive always those 2 error :
Error received
can you help on this please ?
I don't know what is in your HTTP Header Manager, but the system under test complains that you're not providing correct Content-Type header which must be text/xml
I believe if you add this header at least this issue will go away.
Going forward you can just record your test from JMeter 3.x in JMeter 5.x and it will generate relevant HTTP Request samplers and HTTP Header Managers.
More information: Testing REST\SOAP Web services

System.Web.HttpRequest Request - change http protocol version - http 2.0 request

Does HttpRequest support setting the protocol version? I would like to set it to 2.0. Is it possible?
For example, HttpWebRequest has a ProtocolVersion property, but can only be set to 1.0 or 1.1.
Does HttpRequest use any default version? Will it work with HTTP/2?
If my server only supports HTTP/2, will I get an error if I use HttpRequest?
The company is going to be updating systems, to be compatible with HTTP/2. I am looking at some code, and we use HttpRequest, and I have noticed there is no option to set the protocol version. Will this be an issue?
I have also noticed in the code we specify:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

Only one cookie available in response from Mule HTTP operation-based Connector

I'm trying to get a project that was made in Mule 3.4 working in Mule 3.7. In Mule 3.4, using the HTTP endpoint-based Connector it was possible to retrieve multiple cookies from response messages by using:
Object cookieObj = message.getInboundProperty("Set-Cookie");
String cookieValSchoolname = CookieHelper.getCookieValueFromCookies (cookieObj, "schoolname");
String cookieValJSessionId = CookieHelper.getCookieValueFromCookies(cookieObj, "JSESSIONID");
In Mule 3.4, using the HTTP endpoint-based Connector, the inbound property "Set-Cookie" contained an array of all the cookies that are set with Set-Cookie in the http header.
However when I use the same code with the new HTTP operation-based Connector, the inbound property "Set-Cookie" only contains the first cookie and not an array with all cookies.
Can anybody tell me how I can access all cookies using the new HTTP Connector?
Maybe there is a way to retrieve the raw http header, to parse that?
The only other inbound properties the message has are content-length, http.reason, http.status, content-type, server and date.
This is a bug. You can check the fix versions there. Cannot think of any workarounds unfortunately.
As far as Anypoint studio is concerned, mulesoft blog says "Anypoint Studio 5.3 with Mule 3.7.2 released!". If possible have that downloaded and do let us know if the issue is fixed. It might help others too.

ASP.NET Web API: Change Request Headers

A JavaScript client that I have no control over is sending the incorrect HTTP request headers to my Web API services. More specifically, it's using a library that is sending an incorrect OData header.
Is there any way that I can intercept the HTTP request before it hits my services? Can I add/remove/update headers or query string info?
For instance, if I receive the following HTTP header:
GET /Some/API HTTP/1.1
Host: myhost.com:80
MaxDataServiceVersion: 2.0
I'd like to know how to modify it to the following before the OData libraries take over:
GET /Some/API HTTP/1.1
Host: myhost.com:80
MaxDataServiceVersion: 4.0
The header isn't incorrect. Your client expects an OData v2 service and even if you did manipulate the headers, it probably won't be able to understand the response from your server.
But you could use a simple HTTP proxy to rewrite the headers if you really want to try that route.
If you do that, make sure your OData server supports the Atom format because the OData JSON format changed completely between versions 2 and 4, so there's no way that JavaScript client will understand it. The Atom format changed as well, but if the client's parser is extremely lenient, it might work.

HOWTO override Axis2 request headers for .NET web service?

I have to use a 3rd party web service implemented in .NET 2.0 (on IIS, of course).
I have to make a java client. I am using wsdl2java to generate the SOAP stub.
As the original Apache Axis project now appears unmaintained, and I was having some problems parsing some responses from the service, I converted the client to use the latest (1.5) version of Axis2. Now, the .NET service won't even recognize my requests.
I managed to get the "chunking" turned off (where "stub" is a variable of type MumbleStub generated by wsdl2java, and I am showing what are several lines of code as one horrific line here):
stub._getServiceClient().getOptions().setProperty( HTTPConstants.CHUNKED, Boolean.FALSE);
.. so at least the service recognizes my request AS a request, albeit a bad one: "HTTP/1.1 400 Bad Request" is the response now (as opposed to an "intro / summary" page offering me a link to the WSDL).
I noticed that the Axis ("1") request had a different Content-TYpe header (text/xml, vs application/soap-xml), and I am wondering how to change this request header, if that is in fact the problem.
Alternately, has anybody else had this problem? Is the problem really the (undisplayable here, as it looks like "element injection" to the blog engine) ... xml version-"1.0" ... "XML meta intro tag" that Axis2 added to the beginning of the request?
WS-Deathstar, indeed.
As you mention the different content-type header I guess your client tries to send SOAP 1.2 requests and the 3rd party app only understands SOAP 1.1
Try changing the used soap version as AFAIK AXIS2 uses SOAP 1.2 by default
stub._getServiceClient().getOptions().setSoapVersionURI(org.apache.axiom.soap.SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);

Resources