This topic contains 0 replies, has 0 voices, and was last updated by rnedelkow 7 years, 10 months ago.
-
AuthorPosts
-
January 18, 2017 at 2:37 pm #5622
rnedelkowAs of 2017.1, NetSuite is planning changes to the way SuiteScript handles the names of HTTP request headers.
Historically, SuiteScript has required an exact case-sensitive match to identify header names. In the future, this handling will change. This change is being made to align SuiteScript with the HTTP specification. The effects of these changes vary depending on the version of SuiteScript and the method being used. Review this notification, and update your scripts as appropriate.
What Is Changing?
Currently, when NetSuite exposes HTTP request data to a script, it provides the HTTP headers in the same case that they were provided by the requesting client, usually a web browser. This means that, when a SuiteScript attempts to read a request header, the name it uses to check the header value must have the same case that the client provided in the request. Otherwise, the script cannot successfully retrieve the header value. For example, currently, if a header name was provided as Accept-Encoding, a script that refers to the header as accept-encoding does not successfully retrieve the value. However, this behavior will change.
SuiteScript 2.0 and SuiteScript 1.0’s getAllHeaders() Method
For SuiteScript 2.0, and for SuiteScript 1.0’s getAllHeaders() method, the effects of this change are the same: After this change, the system will expose header names in lower-case form. The system will also attempt to add a title case version of each header, which you will see when you retrieve all headers for a request. You can interact with these title case headers as you would with their lower-case counterparts. However, creation of title case headers is not guaranteed, particularly for custom headers. Therefore, for best results, write header names in lower-case letters. In particular, avoid using all-caps or unusual capitalization styles.
For example, suppose your script interacts with a custom header called HOSTTYPE. You should change the following:
if (context.request.headers[‘HOSTTYPE’] === “production”)
To the following:
if (context.request.headers[‘hosttype’] === “production”)
As part of this change, you may notice that when you retrieve all headers for a request, you will in most cases see a longer list of strings. Typically, each header will be represented in both lower-case and title case. Affected Components
What is Changing?
Recommended ActionSuiteScript 2.0
SuiteScript 1.0’s getAllHeaders() methodHeader names will be primarily represented in lower-case. NetSuite will attempt to add a title case representation of each header, but references to headers that include capital letters may no longer return values.
Review your integrations for scripts that reference individual headers by name. Find any cases of header names written using all caps or other unusual capitalization. Review the names of custom headers with particular care. If your script uses any capitalization other than title case, change the string to lower-case. For best results, change all header names to lower-case.When you retrieve all headers for a request, typically you will now see two iterations of each header: one in lower-case and one in title case.
NoneSuiteScript 1.0’s getHeader() Method
In SuiteScript 1.0, there is one exception to the preceding guidance. After this change, when you use the getHeader() method, the system will always read the header name you provide in a case-insensitive manner. Capital letters will not cause problems. For example, both of the following expressions will return the appropriate values:
var myValue = request.getHeader(‘accept-encoding’);
var myValue = request.getHeader(‘AcCePt-EnCoDiNg’); Affected Components
What is Changing?
Recommended ActionSuiteScript 1.0’s getHeader() method
When the getHeader method is used, the system will be more forgiving of the way your script references header names. Code that previously did not return data may begin to return the appropriate values.
Review your integrations for scripts that use the getHeader() method. If any of these scripts are not returning data, be aware that after this change they may begin to return values. Make any adjustments necessary.More Information
For more information about scripting HTTP requests, see the following:For SuiteScript 1.0, see nlobjRequest (SuiteAnswers ID 10270).
For SuiteScript 2.0, see http.ServerRequest (SuiteAnswer ID 44808) and https.ServerRequest (49541).
If you have any questions about these changes, please contact NetSuite Customer Support.
This is a cached copy. Click here to see the original post. -
AuthorPosts
You must be logged in to reply to this topic.