The Artima Developer Community
Sponsored Link

Agile Buzz Forum
Url Verification

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
James Robertson

Posts: 29924
Nickname: jarober61
Registered: Jun, 2003

David Buck, Smalltalker at large
Url Verification Posted: Dec 11, 2008 3:16 PM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: Url Verification
Feed Title: Cincom Smalltalk Blog - Smalltalk with Rants
Feed URL: http://www.cincomsmalltalk.com/rssBlog/rssBlogView.xml
Feed Description: James Robertson comments on Cincom Smalltalk, the Smalltalk development community, and IT trends and issues in general.
Latest Agile Buzz Posts
Latest Agile Buzz Posts by James Robertson
Latest Posts From Cincom Smalltalk Blog - Smalltalk with Rants

Advertisement

I've had a few people tell me that I should have url verification set up before I post videos, podcasts (etc) - and I had another typo trip me up on the Modeling Panel Video yesterday. So this morning, I went ahead and added url verification to my posting tool (the iTunes tag editor, specifically). Here's what I did:

  1. Edited the input field for the url in the GUI builder, adding a validation method
  2. Implemented a method that answers true if the url responds, false otherwise

Now obviously, if the url is for a large video file, I don't want to download the entire thing to validate it - I just want the headers. So here's the method:


checkThatUrlExists: ctrlr
	"check to see whether the URL exists before we move on"

	| toCheck client resp |
	toCheck := ctrlr view editValue.
	('http*' match: toCheck)
		ifFalse: [^false].
	client := Net.HttpClient new.
	resp := [client headers: toCheck]
		on: Net.HttpException
		do: [:ex | nil].
	^resp notNil

If the validation method takes an argument, the controller comes in. I use that to get the edited value (as opposed to the last thing sitting in the model, which will not be what I've entered yet). Then I create the HttpClient, and send a request for just the headers.

If I get any http exception, I assume it's bad - for the purposes of url validation, I'm not that particular about why it failed. In terms of behavior, the tab out of that field fails, and no data for that field has been accepted yet. I should really change the accept button behavior to enable only on a validated field, but this is a UI only I use, so I'm not that worried about it at this point :)

Technorati Tags: ,

Read: Url Verification

Topic: For the Geek who has everything Previous Topic   Next Topic Topic: MPS Goes Beta, Goes Free and Open-source

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use