@@ -25,10 +25,13 @@ settings.AutoGroupResults = GetSetting("AutoGroupResults");
2525local types = {};
2626
2727luanet .load_assembly (" System.Net" );
28+ luanet .load_assembly (" System.Windows.Forms" );
29+
2830types [" System.Net.WebClient" ] = luanet .import_type (" System.Net.WebClient" );
2931types [" System.IO.StreamReader" ] = luanet .import_type (" System.IO.StreamReader" );
3032types [" System.Text.Encoding" ] = luanet .import_type (" System.Text.Encoding" );
3133types [" System.DBNull" ] = luanet .import_type (" System.DBNull" );
34+ types [" System.Windows.Forms.Application" ] = luanet .import_type (" System.Windows.Forms.Application" );
3235
3336luanet .load_assembly (" System" );
3437types [" System.Collections.Specialized.NameValueCollection" ] = luanet .import_type (" System.Collections.Specialized.NameValueCollection" );
@@ -164,6 +167,10 @@ function Init()
164167 catalogSearchForm .Browser :Navigate (settings .BaseURL );
165168end
166169
170+ function Version ()
171+ return types [" System.Windows.Forms.Application" ].ProductVersion ;
172+ end
173+
167174function WebView2Enabled ()
168175 return AddonInfo .Browsers ~= nil and AddonInfo .Browsers .WebView2 ~= nil and AddonInfo .Browsers .WebView2 == true ;
169176end
@@ -747,6 +754,8 @@ function SendApiRequest(apiPath, method, parameters, authToken)
747754 local webClient = types [" System.Net.WebClient" ]();
748755
749756 webClient .Headers :Clear ();
757+ -- Add a user-agent for the API request to support ArchivesSpace API hosted by Lyrasis
758+ webClient .Headers :Add (" user-agent" , " AtlasAeon/" .. Version ());
750759 if (authToken ~= nil and authToken ~= " " ) then
751760 webClient .Headers :Add (" X-ArchivesSpace-Session" , authToken );
752761 end
0 commit comments