Comments (2)
Hi there,
This is quite a special case. Since sitemaps are generally public, I think most sitemap submission services would allow public ping, but I can see how they may want to restrict that to authenticated users to prevent abuse of their systems.
Internally SitemapGenerator uses 'openuri' so if NTLM can be made to work with that then that would be easy. Alternatively it's not a big deal to use Net::HTTP directly like in the ruby-ntlm Readme examples. Then there would need to be some configuration options for the user, password and domain or whatever it is that you need. Not too bad.
The Yandex login example that you sent is a bit trickier because it requires you to fill out a web form to login. That would necessitate using something like Mechanize to fill in the form programatically. That's not super difficult but every web form is different so you're looking at some kind of "adapter" scenario, so you would define a Yandex adapter to do the login and your credentials would probably be stored in the adapter instance. That would be a tall order for me to code up so if you are really interested in it, by all means take a stab at it. The logic would be in the adapter and not much would have to change in LinkSet#ping_search_engines.
If you want to just put something in manually for yourself I think the best way is to just put your code directly into your sitemap config file at the end.
Any thoughts?
from sitemap_generator.
Hi,
So there are 2 problems:
a) ping behind proxy (including NTLM)
b) ping engines that require some authorization.
You said that a) is the feature that will be useful at gem, but the b) problem is "adapter" scenario and you are ready to make stub to implement this stub anybody who interested in specific adapter. Is it correct resume? I agree with you if I understand you resume correctly. I will submit yandex adapter after implementation it by myself.
I don't know does 'openuri' can handle NTLM proxy, I need check it, but P.S. contains code that handle this case by (gem "ruby-ntlm", ">= 0.0.1" gem. May be it will be useful for you.
Artem.
P.S.
Code that handle NTLM proxy case:
# Define http constants
options = {:debug => false, :http_timeout => 60, :method => :get,
:redirect_count => 0, :max_redirects => 10, :headers => {},
:parameters => { :page => 1, :per_page => 100},}
# Configure proxy
if yml_file[::Rails.env]["proxy_host"]
proxy_host = yml_file[::Rails.env]["proxy_host"]
proxy_port = yml_file[::Rails.env]["proxy_port"]
proxy_username = yml_file[::Rails.env]["proxy_username"]
proxy_password = yml_file[::Rails.env]["proxy_password"]
proxy = Net::HTTP::Proxy(proxy_host, proxy_port, proxy_username, proxy_password)
http = proxy.new(url.host, url.port)
else
http = Net::HTTP.new(url.host, url.port)
end
# Set ssl
if url.scheme == 'https'
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
end
# Configure session
http.open_timeout = http.read_timeout = options[:http_timeout]
http.set_debug_output $stderr if options[:debug]
# Make request for post of get
request = case options[:method]
when :post
request = Net::HTTP::Post.new(url.request_uri)
request.set_form_data(options[:parameters])
request
else
Net::HTTP::Get.new(url.request_uri)
end
# Set basic auth
if yml_file[::Rails.env]["username"]
request.basic_auth yml_file[::Rails.env]["username"],
yml_file[::Rails.env]["password"]
end
# Set header and make request
options[:headers].each do |key, value|
request[key] = value
end
# Start a new request, not redirects expects
if yml_file[::Rails.env]["proxy_auth"] == "NTLM"
proxy_domain = yml_file[::Rails.env]["proxy_domain"]
proxy_username = yml_file[::Rails.env]["proxy_username"]
proxy_password = yml_file[::Rails.env]["proxy_password"]
request.ntlm_auth(proxy_username, proxy_domain, proxy_password)
response = http.request(request)
http_response_body = response.body
else
response = http.request(request)
http_response_body = response.body
end
from sitemap_generator.
Related Issues (20)
- Ping failed for Bing: #<OpenURI::HTTPError: 410 Gone> HOT 2
- Feature Request: Remove unwanted options HOT 6
- Is it possible to override the default link options? HOT 3
- How to remove default priority, lastmod and changefreq from all urls HOT 1
- GoogleStorageAdapter - Can't create sitemap on buckets with uniform bucket-level access enabled HOT 3
- Allow disable acl for S3 bucket HOT 1
- Rails on Heroku with S3 sitemap hosting - google didn't like it HOT 2
- 【Worked】Ping failed for Bing: #<OpenURI::HTTPError: 410 Gone> HOT 4
- Is it possible to add additional metadata fields to the xml HOT 5
- Feature request : Make `default_host` optional / Allow full URL instead of path HOT 2
- Entity escaping in XML output
- google search console couldn't fetch sitemap but index is ok HOT 7
- Google search correct ping url HOT 2
- Readme install instructions fail HOT 1
- [BUG] Mobile sitemap link in Readme.md is giving 404
- TimeZone is ignored
- sitemap.xml.gz file not found on server
- Testing with frozen time does not work
- should sitemap show up automatically in google search console? HOT 2
- Should we drop default `lastmod` of `Time.now` as Google says "it needs to consistently match reality"? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sitemap_generator.